我正在尝试使用visifire点图来绘制一些数据,但是我只想要一种颜色,或者如果我添加另一个数据集,而不是彩虹颜色,为我正在绘制的每个数据集做一个不同的颜色。这是我到目前为止所拥有的。
ColorSet ct = new ColorSet();
ct.Id = "MyColorSet";
ct.Brushes.Add(new SolidColorBrush(Colors.Blue));
// Create a Chart element
Chart chart = new Chart();
//Create new instance of ColorSets class
chart.ColorSets = new ColorSets();
chart.ColorSets.Add(ct);
chart.ScrollingEnabled = false;
chart.AnimatedUpdate = true;
// Set chart width and height
chart.Width = 1400;
chart.Height = 400;
chart.ZoomingEnabled = true;
// Create new DataSeries
DataSeries dataSeries = new DataSeries();
dataSeries.RenderAs = RenderAs.Point;
dataSeries.MarkerType = MarkerTypes.Triangle;
dataSeries.MarkerSize = 3.5;
// Loop and add a few DataPoints
for (int loopIndex = 0; loopIndex < numOfPoints; loopIndex++)
{
// Create a DataPoint
DataPoint dataPoint = new DataPoint();
// Set the YValue using random number
dataPoint.YValue = arr[loopIndex].mass;
dataPoint.XValue = arr[loopIndex].num;
// Add DataPoint to DataSeries
dataSeries.DataPoints.Add(dataPoint);
}
// Add DataSeries to Chart
chart.Series.Add(dataSeries);
// Add chart to the LayoutRoot for display
ChartGrid.Children.Add(chart);
答案 0 :(得分:1)
我明白了。
System.Windows.Media.Brush brush = new SolidColorBrush(Colors.DarkRed);
dataSeries.Color = brush;