【问题标题】:Telerik RadCartesianChart BarSeries StyleTelerik RadCartesianChart BarSeries 样式
【发布时间】:2017-05-29 18:15:44
【问题描述】:

我在 Telerik WPF 中有一个 Bar Series 的 Radcartesianchart,每个 Bar 的值是两个值的百分比,如果该值小于 98%,我需要将条形颜色更改为红色,并且需要更改条形颜色如果值超过 97%,则变为绿色,但我所看到的所有事情都会改变意甲中所有条形的颜色,并且不会发生小于我的目标百分比的条形,有人可以在这个问题上提供帮助吗?

【问题讨论】:

    标签: c# wpf telerik


    【解决方案1】:

    我已经完成了使用 StyleSelector 到 Barseries 的这项工作。

    public override Style SelectStyle(object item,
                DependencyObject container)
            {
                if (SetColor)
                {
                    Style st = new Style();
                    var _item = (item as CategoricalDataPoint);
                    st.TargetType = typeof(Border);
                    Setter backGroundSetter = new Setter();
                    backGroundSetter.Property = Border.BackgroundProperty;
    
                    if (_item.Value < 98)
                    {
                        backGroundSetter.Value = Brushes.Red;
                    }
                    else
                    {
                        backGroundSetter.Value = Brushes.Lime;
                    }
                    st.Setters.Add(backGroundSetter);
                    return st;
                }
                else
                    return null;
            }
    

    Ande 在 Barseries 参数中设置此项

    RadChart.Series.Add(new BarSeries()
                    {
                        ShowLabels = true,
                        ClipToPlotArea = true,
                        DefaultVisualStyleSelector = editor.selector,
                        ItemsSource = editor.ItemSourceOptions[i],
                        ValueBinding = new PropertyNameDataPointBinding(editor.SeriesItemsNames[i]),
                        CategoryBinding = new PropertyNameDataPointBinding(editor.CategoryNames[i])
                    });
    

    【讨论】:

      猜你喜欢
      • 2013-02-16
      • 2016-11-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-11-09
      • 1970-01-01
      相关资源
      最近更新 更多