I am trying to bind two series to a chart that use a daterange to income amount. The problem I am having is that after I add the individual series they get plotted against the first date in the graph, and then just plot against each point, which isn't the same as in the data. Now I may be doing this wrong but I am unsure of the best way to do it so I will try to explain how this is currently working.
- I create a dataset report from our database
- This data can have multiple locations and are setup with different ID numbers, I need these numbers as different series on the chart
- I take my dataset and a create new datatables as queries based on these ID numbers, so now I have loads of different tables with the relevant data in along with the date fields.
- I then create series dynamically and setup the required table names to the series, they all use the same X / Y access - which is Date, and Value
- I then create my charge by adding each series to it, I then setup the chart axis with the dates based on the first initial table that was created (the one that contains all dates in the correct order).
I create the series based on different table names with the following code -
Dim tablename As String = "Table"
For Each chartseries As ChartSeriesSetup In chart.chartseries
If chartseries.TableName <> "" Then tablename = chartseries.TableName Else tablename = "Table"
Dim model As New ChartDataBindModel(chart.ds, tablename)
model.XName = chartseries.xname
model.YNames = chartseries.yname
Dim series As New ChartSeries(chartseries.seriesname, chartseries.ChartType)
series.Text = chartseries.seriesname
series.Style.Interior = New BrushInfo(chartseries.seriescolour)
series.SeriesIndexedModelImpl = model
series.SmartLabels = True
series.Style.DisplayText = chartseries.displaytext
series.Style.TextOrientation = chartseries.labelposition
series.Style.Border.Width = chartseries.borderwidth
I then setup the chart axis with the following (note the table name compred to above series creation) -
xAxisLabelModel = New ChartDataBindAxisLabelModel(chart.ds, "Table")
ChartControl1.PrimaryXAxis.LabelsImpl = xAxisLabelModel
The same dataset contains all the other tables with the broken down data in.
I show the chart as a line chart
The chart does plot, but it plots against the dates in order 1 after another, which is incorrect, as some dates don't have income for that location.
01/01/2016 location 1, 500 income
01/01/2016 location 2, 600 income
02/01/2016 location 1, 400 income
03/01/2016 location 2, 500 income
etc thus i want my graph to skip these dates while drawing.
It will be difficult to provide a code sample of this due to everything being created dynamically across multiple classes - so I hope you can understand what I am trying to do, and can instruct me on the best way to do it.
The upshot is I have data in a table that I wish to filter by location (which is one field) and apply multiple series on the graph via this location.
I attached an image so you can see what the chart ends up like