简体   繁体   中英

LiveCharts: how to plot skewed data (i.e exponential y-axis) in column series wpf

How to set the Y-axis interval exponentially in column series?

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
}

You can configure your y-axis with a logarithmic scale - there's an explanation of how to do this on the Live Charts site https://lvcharts.net/App/examples/v1/wpf/Logarithmic%20Scale

Here's an example adapted for a column series:

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;
}

and the XAML:

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

带对数刻度的列系列

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM