I use a LineSeries show points in a ChartView with data binding.
I want to change specific point style by specific condition from bound data.
How to do that?
Example: if data value bigger than 10 and change the point size to bigger.
5 Answers, 1 is accepted
The following help article demonstrates how to use data binding for populating a LineSeries with data: https://docs.telerik.com/devtools/winforms/controls/chartview/populating-with-data/binding-to-datatable
The LineSeries offers several properties that may be useful for styling the lines and their points:
- BorderWidth: The property determines the thickness of the lines.
- PointSize: The property denotes the size of the points.
If you need to customize certain point values in a different size, please have a look at the following code snippet which result is illustrated in the screenshot:
DataTable table = new DataTable();
table.Columns.Add("Value", typeof(double));
table.Columns.Add("Name", typeof(string));
table.Rows.Add(1, "John");
table.Rows.Add(13, "Adam");
table.Rows.Add(5, "Peter");
table.Rows.Add(12, "Sam");
table.Rows.Add(6, "Paul");
LineSeries lineSeria = new LineSeries();
radChartView1.Series.Add(lineSeria);
lineSeria.ValueMember = "Value";
lineSeria.CategoryMember = "Name";
lineSeria.DataSource = table;
lineSeria.PointSize = new SizeF(8, 8);
lineSeria.BorderColor = Color.Red;
lineSeria.BorderWidth = 1;
foreach (CartesianLinePointElement pointElement in lineSeria.Children)
{
CategoricalDataPoint dataPoint = pointElement.DataPoint as CategoricalDataPoint;
if (dataPoint.Value > 10)
{
pointElement.BackColor = Color.Aqua;
}
}
I hope this information helps. If you need any further assistance please don't hesitate to contact me.
Regards,
Dess | Tech Support Engineer, Sr.
Progress Telerik
Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.
Hi, Johnny,
If you are using live data, I suppose that the data is being changed at a certain interval. Hence, after each update iteration, you can enumerate the LineSeries.Children and adjust the desired point elements according to your custom requirements.
Our Demo application >> ChartView >> Live Data example may be useful for your scenario.
Should you have further questions please let me know.
Regards,
Dess | Tech Support Engineer, Sr.
Progress Telerik
Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.
My preferred way.
https://www.telerik.com/forums/are-there-any-samples-for-drawing-points-on-lineseries#2pSeTCT61EyVN9VWeT9mQA
Hello, Johnny,
I have already reviewed the custom implementation that you have. I am glad that you have found a suitable solution for your precise case.
If you need any further assistance please don't hesitate to contact me.
Regards,
Dess | Tech Support Engineer, Sr.
Progress Telerik
Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.