[C#]
ChartSeries series1 = new ChartSeries("Technology AAA", ChartSeriesType.Scatter);
series1.Points.Add(500, 356, 3);
series1.Points.Add(1000, 491, 4);
series1.Points.Add(1500, 382, 3);
series1.Points.Add(2000, 437, 3);
series1.Points.Add(2500, 351, 4);
ChartSeries series2 = new ChartSeries("Technology BBB", ChartSeriesType.Scatter);
series2.Points.Add(500, 175, 4);
series2.Points.Add(1000, 291, 3);
series2.Points.Add(1500, 182, 2);
series2.Points.Add(2000, 237, 4);
series2.Points.Add(2500, 151, 4);
ChartSeries series3 = new ChartSeries("Technology BBB", ChartSeriesType.Scatter);
series3.Points.Add(500, 250, 5);
series3.Points.Add(1000, 391, 2);
series3.Points.Add(1500, 282, 4);
series3.Points.Add(2000, 387, 2);
series3.Points.Add(2500, 251, 4);
chart.Series.Add(series1);
chart.Series.Add(series3);
chart.Series.Add(series2);
Random r = new Random();
for(int i=0;i<chart.Series.Count; i++)
{
for (int j = 0; j < chart.Series[i].Points.Count; j++)
{
chart.Series[i].Styles[j].Interior = new Syncfusion.Drawing.BrushInfo(Color.FromArgb(r.Next(0, 256), r.Next(0, 256), r.Next(0, 256)));
}
} |
Thank you for the reply and example.
How would the user looking at the chart know what value the color represents?
I'm looking for something similar to the attached file.
Thanks
[C#]
public void InitializeChartData()
{
Color[] colors = { Color.Green, Color.Red, Color.Orange, Color.MistyRose, Color.Purple, Color.Azure, Color.Brown, Color.Crimson, Color.DarkOrchid };
ChartSeries series1 = new ChartSeries("Technology AAA", ChartSeriesType.Scatter);
series1.Points.Add(1, 356, 3);
series1.Points.Add(2, 491, 4);
series1.Points.Add(3, 382, 1);
series1.Points.Add(4, 437, 2);
series1.Points.Add(5, 351, 5);
ChartSeries series2 = new ChartSeries("Technology BBB", ChartSeriesType.Scatter);
series2.Points.Add(1, 175, 2);
series2.Points.Add(2, 291, 5);
series2.Points.Add(3, 182, 4);
series2.Points.Add(4, 237, 1);
series2.Points.Add(5, 151, 3);
ChartSeries series3 = new ChartSeries("Technology BBB", ChartSeriesType.Scatter);
series3.Points.Add(6, 250, 5);
series3.Points.Add(7, 391, 2);
series3.Points.Add(8, 282, 3);
series3.Points.Add(9, 387, 1);
series3.Points.Add(10, 251, 4);
chart.ShowToolTips = true;
series1.PrepareStyle += new ChartPrepareStyleInfoHandler(ChartControlSeries_PrepareStyle);
series2.PrepareStyle += new ChartPrepareStyleInfoHandler(ChartControlSeries_PrepareStyle);
series3.PrepareStyle += new ChartPrepareStyleInfoHandler(ChartControlSeries_PrepareStyle);
chart.Series.Add(series1);
chart.Series.Add(series3);
chart.Series.Add(series2);
Random r = new Random();
for (int i = 0; i < chart.Series.Count; i++)
{
for (int j = 0; j < chart.Series[i].Points.Count; j++)
{
ChartPoint point = chart.Series[i].Points[j];
Color pointColor = colors[Convert.ToInt32(point.YValues[1])];
chart.Series[i].Styles[j].Interior = new Syncfusion.Drawing.BrushInfo(pointColor);
}
}
chart.Legend.Visible = false;
this.Controls.Add(chart);
}
protected void ChartControlSeries_PrepareStyle(object sender, ChartPrepareStyleInfoEventArgs args)
{
ChartSeries series = sender as ChartSeries;
if (series != null)
{
args.Style.ToolTip = "X : " + series.Points[args.Index].X.ToString() + ", Y : " + series.Points[args.Index].YValues[0].ToString() + ", Z : " + series.Points[args.Index].YValues[1].ToString();
args.Handled = true;
}
} |