We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Chart Series Problem

Hello,

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
            ChartControl1.Series.Add(series)
        Next

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.

example:
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

Thank You.

Attachment: marketincomechart_feab68b4.zip

5 Replies

AB Akbar Basha K M Syncfusion Team August 15, 2016 07:21 AM UTC

Hi Ashley, 
Thanks for contacting syncfusion support. we cannot understand your exact scenarios. Could you please provide more information about this. 
If you want to prevent certain points from getting plotted, can you please use IsEmpty property of the chart point as true. 
To know more details about empty point please refer the below link, 
If this is not meet your exact requirement can you please revert and modifying the attached sample along with replication procedure. It would be more helpful to provide better solution soon. 
Sample Location:http://www.syncfusion.com/downloads/support/directtrac/159905/ze/Plotted_Series-453370242 
Please let us know if you have any concern. 
Thanks 
Akbar Basha KM 



AB Ashley Bates August 15, 2016 08:38 AM UTC

Hello,

I will try to explain what I am trying to do simply -

I have data that I wish to break down into two series and plot on my graph against dates.

This data has location fields which I want to use as the breakdown.

So all location 1 should be filtered into one series
All location 2 should be filtered into another series

Then on the graph when the points are plotted against the dates I want the points to be plotted only against the dates relevant to that data. As an example of what my datatable looks like -

Date
Location
Total
01/01/2016
1
100
02/01/2016
2
200
03/01/2016
1
300
04/01/2016
2
400

so on my chart, my xaxis has all 4 dates, however i am trying to split up the two series as location 1, and location 2, thus they should only have two plot points each on the chart. Currently - it does this wrong, they plot from the start of the chart... so location 1 data points are plotted against the 01/01/2016, and 02/01/2016... INSTEAD OF 01/01/2016, and 03/01/2016.

What I attempted to do was create two additional data tables for the series, so that the data was filtered, then use the initial data table as a list of dates for the xaxis - but clearly doesn't seem a good way to do it.

I hope this is clearer for you.

Thank You.




DD Dharanidharan Dharmasivam Syncfusion Team August 16, 2016 05:47 PM UTC

Hi Ashley, 
  
We have analyzed your query and not able to reproduce the mentioned issue at our end. We have created sample based on your requirement. Created a table and populated the data using sql in which we have bind the data based on the location. If location is 1 , binded the data to one series and if location is 2 , binded data to another series. Find the screenshot and code snippet. 
  
Screenshot: 
 
  
Code snippet: 
VB: 
  
            Dim cmd As New SqlCommand("SELECT * FROM [SampleTable] WHERE location = '1' ", con) 
            Dim cm As New SqlCommand("SELECT * FROM [SampleTable] WHERE location = '2' ", con) 
            con.Open() 
            Dim cd As New SqlDataAdapter(cmd.CommandText, con) 
            Dim ser As New SqlDataAdapter(cm.CommandText, con) 
            cd.Fill(dt) 
            ser.Fill(seri) 
            Dim model1 As New ChartDataBindModel(dt) 
            model1.YNames = {"total"} 
            model1.XName = "date" 
            Dim model2 As New ChartDataBindModel(seri) 
            model2.YNames = {"total"} 
            model2.XName = "date" 
  
  
Data in DataTable: 
 
  
  
For your reference we have attached the sample, kindly find the sample from the below link 
  
Thanks, 
Dharani. 
  
  



AB Ashley Bates August 17, 2016 11:50 AM UTC

Thank You

I have this working now - although I had to mess around with my code a bit.

The main culprits were the fact I had my series setup with -
                series.SeriesIndexedModelImpl = model

and I didn't index my chart -
                ChartControl1.Indexed = True




DD Dharanidharan Dharmasivam Syncfusion Team August 18, 2016 12:16 PM UTC

Hi Ashley, 

Thanks for your update. If you need any further assistance, kindly revert us back. 

Thanks, 
Dharani. 


Loader.
Up arrow icon