2013-04-23 38 views
0

我想繪製一些使用visifire點圖的數據,但不是有彩虹色,而只是想要一種顏色,或者如果我添加其他數據集,我正在繪製每個數據集。這是我到目前爲止。只有一種顏色的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);  

回答

1

我想通了。

System.Windows.Media.Brush brush = new SolidColorBrush(Colors.DarkRed); 
dataSeries.Color = brush; 
相關問題