【问题标题】:WPF Telerik Scatter Point colorsWPF Telerik 散点图颜色
【发布时间】:2020-08-25 13:13:32
【问题描述】:

我是 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,0" TextWrapping="Wrap" Text="Well points on X Axis" VerticalAlignment="Top" Width="248"/>

            <TextBlock Grid.Column="2" HorizontalAlignment="Left" Margin="389,35,0,0" TextWrapping="Wrap" Text="Well points on Y axis" VerticalAlignment="Top" Width="243"/>

非常感谢你的努力

【问题讨论】:

标签: c# wpf colors telerik


【解决方案1】:

您可以使用 Telerik 的 PointTemplateSelector。这允许在代码中动态自定义每个点。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-10-12
    • 2014-09-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-05-04
    • 2011-08-29
    • 1970-01-01
    相关资源
    最近更新 更多