问题描述
我是WPF telerik技术框架的初学者。 我希望自定义颜色指向Telerik散点图中的点。但是,点的颜色没有改变。我该怎么办?我所做的事情有根本的错误吗? 这是C#代码
var pallate = ColorPallate();
var PS = new ScatterPointSeries();
var pallaet = new ChartPalette();
PaletteEntryCollection pall = new PaletteEntryCollection();
for (int i = 0; i < data.GetLength(0); i++)
{
ScatterDataPoint point = new ScatterDataPoint();
point.XValue = data[i,XAxisIndex];
point.YValue = data[i,YAaxisIndex];
int value = 0;
if (!float.IsNaN(PredictedResult[i]))
value = System.Convert.ToInt32(PredictedResult[i]);
var filler = new PaletteEntry();
filler.fill(pallate[value]);
pall.Add(filler);
PS.DataPoints.Add(point);
}
pallaet.SeriesEntries.Add(pall);
this.Cross_Plot.Palette = pallaet;
其中ColorPallate()提供自定义颜色调色板
private Brush[] ColorPallate()
{
var pallate = new Brush[15];
pallate[0] = new SolidColorBrush(Colors.Red);
pallate[1] = new SolidColorBrush(Colors.Orange);
pallate[2] = new SolidColorBrush(Colors.Green);
pallate[3] = new SolidColorBrush(Colors.Pink);
pallate[4] = new SolidColorBrush(Colors.Black);
pallate[5] = new SolidColorBrush(Colors.brown);
pallate[6] = new SolidColorBrush(Colors.Crimson);
pallate[7] = new SolidColorBrush(Colors.DarkOrange);
pallate[8] = new SolidColorBrush(Colors.ForestGreen);
pallate[9] = new SolidColorBrush(Colors.Indigo);
pallate[10] = new SolidColorBrush(Colors.DarkKhaki);
pallate[11] = new SolidColorBrush(Colors.Purple);
pallate[12] = new SolidColorBrush(Colors.Gold);
pallate[13] = new SolidColorBrush(Colors.Rosybrown);
pallate[14] = new SolidColorBrush(Colors.Gray);
return pallate;
}
这是XMAL代码
<telerik:RadCartesianChart x:Name="Cross_Plot" Margin="0,51,17,0" VerticalAlignment="Top" Height="472" Grid.Column="2" HorizontalAlignment="Right" Width="1057" Grid.RowSpan="2" >
<telerik:RadCartesianChart.HorizontalAxis>
<telerik:Linearaxis SmartLabelsMode="SmartStep" MajorTickOffset="0"/>
</telerik:RadCartesianChart.HorizontalAxis>
<telerik:RadCartesianChart.VerticalAxis>
<telerik:Linearaxis SmartLabelsMode="SmartStep" ElementBrush="Black" />
</telerik:RadCartesianChart.VerticalAxis>
<telerik:ScatterPointSeries XValueBinding="XValue" YValueBinding="YValue" ItemsSource="{Binding}">
<telerik:ScatterPointSeries.DefaultVisualStyle>
<Style targettype="Path">
<Setter Property="Fill" Value="{Binding RelativeSource={RelativeSource Mode=Self},Path=Tag.DataItem.Color}" />
<Setter Property="Width" Value="10" />
<Setter Property="Height" Value="10" />
</Style>
</telerik:ScatterPointSeries.DefaultVisualStyle>
</telerik:ScatterPointSeries>
</telerik:RadCartesianChart>
<TextBlock Grid.Column="2" HorizontalAlignment="Left" Margin="131,37,0" textwrapping="Wrap" Text="Well points on X Axis" VerticalAlignment="Top" Width="248"/>
<TextBlock Grid.Column="2" HorizontalAlignment="Left" Margin="389,35,0" textwrapping="Wrap" Text="Well points on Y axis" VerticalAlignment="Top" Width="243"/>
非常感谢您的努力
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)