常数将AxisY从0更改

时间:2018-10-02 23:16:34

标签: c# wpf livecharts

我正在尝试使用此示例,但我有一个疑问,如何使Y轴从0开始?

在示例中,它从Y轴上的最小值开始 https://i.imgur.com/UcjTejd.png

https://lvcharts.net/App/examples/v1/wpf/Constant%20Changes

1 个答案:

答案 0 :(得分:0)

我找到了解决方法

 <Wpf:CartesianChart Grid.Row="1" AnimationsSpeed="0:0:0.5" Hoverable="False" DataTooltip="{x:Null}">
        <Wpf:CartesianChart.Series>
            <Wpf:LineSeries Values="{Binding ChartValues}" 
                            PointGeometry="{x:Null}" 
                            LineSmoothness="1"
                            StrokeThickness="1" 
                            Stroke="#F34336"
                            Fill="Transparent"/>
        </Wpf:CartesianChart.Series>
        <Wpf:CartesianChart.AxisX>
            <Wpf:Axis LabelFormatter="{Binding DateTimeFormatter}" 
                      MaxValue="{Binding AxisMax}" 
                      MinValue="{Binding AxisMin}"
                      Unit="{Binding AxisUnit}">
                <Wpf:Axis.Separator>
                    <Wpf:Separator Step="{Binding AxisStep}" />
                </Wpf:Axis.Separator>
            </Wpf:Axis>
        </Wpf:CartesianChart.AxisX>

 #region This set Axis Y start from 0
        <Wpf:CartesianChart.AxisY>
            <Wpf:Axis MinValue="0">
                <Wpf:Axis.Separator>
                    <Wpf:Separator/>
                </Wpf:Axis.Separator>
             </Wpf:Axis>
            </Wpf:CartesianChart.AxisY>
#endregion