X Axis datasource has 60 elements starting at 0..60 chart shows 0 1 10..19 2 20..

So I get 0 1 10 11 12 13 14 15 16 17 18 19 2 20 and the last 4 are 6 7 8 9

The Chart is a bar graph and the data is mixed up on the chart

the datasource is correct though

chart.JPG

Here is the data bar 59 is value of 1 but you see bars 6,7,8 and 9 are out of place at the end of the chart.

data.JPG

I am using a circular buffer of 60 bytes so it wraps around. It receives streaming data.

code below:

public void FillChart2(int currcount)

{

dataSource.Clear();

txtDebug1.Text = "";

int i;

int j = 0;

for (j = 0; j < 60; j++)

{

i = currcount + j;

if (i > 59)

{

i = i - 60;

}

dataSource.Add(new SalesData(j.ToString(), 0, (double)tickArray[i]));

txtDebug1.Text += tickArray[i].ToString();

}

UpdateChart1();

}


public void UpdateChart1()

{

this.chartControl1.Series.Clear();

CategoryAxisDataBindModel dataSeriesModel0 = new CategoryAxisDataBindModel(dataSource);

dataSeriesModel0.CategoryName = "Year"; dataSeriesModel0.YNames = new string[] { "Year" };

ChartSeries chartSeries0 = new ChartSeries("Year"); chartSeries0.CategoryModel = dataSeriesModel0;


CategoryAxisDataBindModel dataSeriesModel = new CategoryAxisDataBindModel(dataSource);

dataSeriesModel.CategoryName = "Year"; dataSeriesModel.YNames = new string[] { "Sales" };

ChartSeries chartSeries = new ChartSeries("Sales"); chartSeries.CategoryModel = dataSeriesModel;


CategoryAxisDataBindModel dataSeriesModel1 = new CategoryAxisDataBindModel(dataSource);

dataSeriesModel1.CategoryName = "Year"; dataSeriesModel1.YNames = new string[] { "Cost" };

ChartSeries chartSeries1 = new ChartSeries("Cost"); chartSeries1.CategoryModel = dataSeriesModel1;


this.chartControl1.PrimaryXAxis.ValueType = ChartValueType.Category;

this.chartControl1.Series.Add(chartSeries);

this.chartControl1.Series.Add(chartSeries1);

}



1 Reply

YP Yuvaraj Palanisamy Syncfusion Team June 30, 2021 10:20 AM UTC

Hi Mark, 
 
Greetings from Syncfusion. 
 
We have analyzed your query and we would like to inform that the reported problem has been resolved by using Sorting support for chart series. Please find the code example below. 
 
CodeSnippet: 
this.chartControl1.PrimaryXAxis.ValueType = ChartValueType.Double;

 
//Sort by chart series 1 
chartSeries1.SortPoints = true; 
chartSeries1.SortOrder = ChartSeriesSortingOrder.Ascending; 
chartSeries1.SortBy = ChartSeriesSortingType.X; 
 
// Sort by chart series 2
chartSeries2.SortPoints = true;
 
chartSeries2.SortOrder = ChartSeriesSortingOrder.Ascending; 
chartSeries2.SortBy = ChartSeriesSortingType.X; 
 
Output: 
 
 
For more details, please refer the below link. 
 
Please let us know if you have any concern. 
 
Regards, 
Yuvaraj. 


Loader.
Up arrow icon