This is a migrated thread and some comments may be shown as answers.

Dynamic Creation of colored RadChart Scatter Series

1 Answer 162 Views
ChartView
This is a migrated thread and some comments may be shown as answers.
Usama
Top achievements
Rank 1
Veteran
Usama asked on 09 Nov 2020, 03:31 PM

Hi, I am new in telerik and (front-end). For my app I want to create dynamic Rad Cartisian chart ,fill it with scatter data points dynamically such that each data point should have predefined color. and store that dynamic created chart in tileview.

Problem is in assigning colors to each point. I would be very grateful if you can guide me in code.

  public RadTileViewItem CreateScatterPlotTile()
        {
            var chart = new Telerik.Windows.Controls.RadCartesianChart();
            var verticalaxis = new Telerik.Windows.Controls.ChartView.LinearAxis();
            var horizentalaxis = new Telerik.Windows.Controls.ChartView.LinearAxis();
            verticalaxis.Visibility = System.Windows.Visibility.Hidden;
            horizentalaxis.Visibility = System.Windows.Visibility.Hidden;

            chart.VerticalAxis = verticalaxis;

            chart.HorizontalAxis = horizentalaxis;

            ScatterPointSeries scatterSeries = new ScatterPointSeries();
            for (int i = 0; i < 100; i++)
            {
                ScatterDataPoint point = new ScatterDataPoint();
                point.XValue = xvaluelist[i];
                point.YValue = yvaluelist[i];
                scatterSeries.DataPoints.Add(point);
            }        
            chart.Series.Add(scatterSeries);
            var tile = new RadTileViewItem();
            tile.Content = chart;

            return tile;
        }  

 

Similarly I have color value list, How can I add colors from my list to each point.

1 Answer, 1 is accepted

Sort by
0
Martin Ivanov
Telerik team
answered on 12 Nov 2020, 11:20 AM

Hello Usama,

The ScatterDataPoint doesn't have an API for assigning color. You can color the data point using the DefaultVisualStyle or the PointTemplate of the series and also the corresponding style/point selectors. Coloring the data points in different colors per the data point value is most convenient in a data binding scenario. You can see how to achieve this in the Binding the Color of Series Items article. Additionally, you can use the palette feature and use the built-in colors or define a custom palette using your own colors.

I hope this helps.

Regards,
Martin Ivanov
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/.

Tags
ChartView
Asked by
Usama
Top achievements
Rank 1
Veteran
Answers by
Martin Ivanov
Telerik team
Share this question
or