I am using VS 2015 and I want to display a data table I have created as a chart.
The data table looks like this.
I havent really used charts before and I have tried a few examples/tutorials found online but I am not getting anywhere.
I would like a line chart with the x axis as timestamp, y as value and 3 lines (in this example) for each tag name.
I have added the control to the page using
<asp:Chart ID="Chart1" runat="server">
.Points.DataBind(trendTagData, "timestamp", "Value", Nothing)
VB is really not my thing, but this is a one-liner:
Chart1.DataBindCrossTable(dt.DefaultView, "tagname", "timestamp", "value", "");
You may also need to do this, AFTER you call
DataBindCrossTable, in order to get a
Line chart type:
Chart1.Series["tag1"].ChartType = SeriesChartType.Line; Chart1.Series["tag2"].ChartType = SeriesChartType.Line; Chart1.Series["tag3"].ChartType = SeriesChartType.Line;
if you don't know how many tag names are in your table, do this:
foreach (Series s in Chart1.Series) s.ChartType = SeriesChartType.Line;
Also, note you can remove
Series1 from your ASPX markup.