Skip to content

Asp chart control

Dinesh Santhalingam

Asked Dec 15, 2016, 12:19 AM EST1 answer
Share
LinkedInX
  1. data table dt = new data table ();  
  2.   DataView dv = new DataView(dt);  
  3.   dv.RowFilter = ("Id='License1'");  
  4.    Chart1.DataSource = dv;  
  5.     Chart1.DataBind();  

 
I have a data table consist of three rows id,use,name.I want to create a line chart using asp chart control .In my above code The chart will drawn for the license 1 column .But I wish to create multi series charts.How can i do suggest some ideas through coding.
 id
 
 Use Time
 License1 1 1
  License1 2 2
  License1 3 3
  License1 4 4
  License1 5 5
  License2 6 1
  License2 7 2
  License2 8 3
  License2 9 4
  License2 10 5

1 Answer

Know the answer? Post it. Somebody with the same question will find it here.

  • 0
    Code
      DataTable dt = new DataTable();
            dt.Columns.Add("Id");
            dt.Columns.Add("Use");
            dt.Columns.Add("Time");
    
      Chart1.DataSource = dt;
     
    Code
       Chart1.Series[0].XValueMember = "Id";
                Chart1.Series[0].YValueMembers = "Use";
    
                Chart1.Series[1].XValueMember = "Id";
                Chart1.Series[1].YValueMembers = "Time";
    
    
    
      Chart1.DataBind();
     
     
     
    .aspx:
     
    <asp:Chart ID="Chart1" runat="server" Width="947px" BorderlineDashStyle="Solid" BorderlineColor="Black" Visible="true">
    <Series>
    <asp:Series ChartType="Line" Color="Red"></asp:Series>
    <asp:Series ChartType="Line" Color="blue"></asp:Series></Series>
    <ChartAreas>
    <asp:ChartArea Name="ChartArea1" Area3DStyle-Enable3D="false">
    <AxisX LineColor="DarkGray"><MajorGrid LineColor="LightGray" /></AxisX>
    <AxisY LineColor="DarkGray"><MajorGrid LineColor="LightGray" /></AxisY>
    <Area3DStyle Enable3D="false"></Area3DStyle>
    </asp:ChartArea>
    </ChartAreas>
    </asp:Chart>
     
    I hope it is useful for you 
     
    0