LiveCharts:如何在列系列wpf中绘制偏斜数据(即指数y轴)

时间:2017-11-03 09:24:29

标签: c# .net wpf livecharts

如何在列系列中以指数方式设置Y轴间隔?

new ColumnSeries
{
     Fill = new SolidColorBrush(Color.FromRgb(30,130,173)),
     Width = 100,
     MaxColumnWidth = 100,
     Values = new ChartValues<double> {500,30,10},
     DataLabels = true,
     LabelPoint  = point => point.Y +"",
     FontSize = 20
}

1 个答案:

答案 0 :(得分:0)

您可以使用对数刻度配置您的y轴 - 有关如何在实时图表网站https://lvcharts.net/App/examples/v1/wpf/Logarithmic%20Scale

上执行此操作的说明

以下是适用于列系列的示例:

public SeriesCollection SeriesCollection { get; set; }

public MainWindow()
{
    InitializeComponent();

    var mapper = Mappers.Xy<double>()
                    .X((value, index) => index)
                    .Y((value, index) => Math.Log(value, 10));

    SeriesCollection = new SeriesCollection(mapper)
    {
        new ColumnSeries
        {
            Values = new ChartValues<double>{500,30,10}
        }
    };

    DataContext = this;
}

和XAML:

<Grid>
    <lvc:CartesianChart Series="{Binding SeriesCollection}">
        <lvc:CartesianChart.AxisY>
            <lvc:LogarithmicAxis Base="10" />
        </lvc:CartesianChart.AxisY>
    </lvc:CartesianChart>
</Grid>

Column series with log scale