1

我正在尝试更改动态创建的系列中的线条粗细,我需要将线条变粗。

下面,按照代码将创建的系列绑定到图表组件上。它工作正常,但我尝试在这段代码中进行调整,但没有成功。

请帮忙,谢谢。

Style style = new Style(typeof(LineDataPoint));
style.Setters.Add(new Setter(LineDataPoint.OpacityProperty, (double)(0.0)));
style.Setters.Add(new Setter(LineDataPoint.BackgroundProperty, dadosSerie.ColorSerie));

LineSeries lineSerie = new LineSeries()
{
    Title = dadosSerie.SerieTitle,
    IndependentValueBinding = new Binding("Key"),
    DependentValueBinding = new Binding("Value"),
    DependentRangeAxis = dadosSerie.EixoY,
    DataPointStyle = style,
    ItemsSource = dadosSerie.DataSerie,
};

chtGraficos.Series.Add(lineSerie);
4

1 回答 1

1

您是否尝试过为系列的折线添加样式?它接缝 LineDataPoint 的样式实际上适用于意甲的每个点。

这是在代码隐藏上完全创建的图表的工作示例。您只需创建一个名为 MainWindow 的窗口并将项目的引用添加到 System.Windows.Controls.DataVisualization.Toolkit:

public partial class MainWindow : Window
{
    public MainWindow()
    {
        InitializeComponent();

        var valueList = new Dictionary<string, int>();
        valueList.Add("Developer", 60);
        valueList.Add("Misc", 20);
        valueList.Add("Project Manager", 40);

        var style = new Style(typeof(Polyline));
        style.Setters.Add(new Setter(Polyline.StrokeThicknessProperty, 10d));

        var series = new LineSeries
        {
            PolylineStyle = style,
            ItemsSource = valueList,
            DependentValuePath = "Value",
            IndependentValuePath = "Key",
        };

        var lineChart = new Chart { Height = 254 };
        lineChart.Series.Add(series);

        var mainGrid = new Grid();
        mainGrid.Children.Add(lineChart);

        this.Content = mainGrid;
    }
}
于 2015-05-15T21:53:06.140 回答