Livecharts not displaying Label on x axis in WPF

ぐ巨炮叔叔 提交于 2019-12-11 12:59:20

问题


I am displaying data in my livecharts and Label values are binded (visible in debugging). But somehow in the UI, it is showing one or two values instead of all the values in string array from the backend.

Model.cs Code:

private string[] _Labels;
public string[] Labels
{
    get
    {
        return _Labels;
    }
    set
    {
        SetProperty(ref _Labels, value);
    }
}

ModelViewCode.cs

Labels = new[] {"Maria", "Susan", "Charles", "Frida"};

XAML:

<lvc:CartesianChart.AxisX>
    <lvc:Axis Labels="{Binding Labels}">
    </lvc:Axis>
</lvc:CartesianChart.AxisX>

Screenshot


回答1:


Define an AxisSeparator for your axis like this, and set its Step property to 1

<lvc:CartesianChart.AxisX>
    <lvc:AxesCollection>
        <lvc:Axis Labels="{Binding Labels}">
            <lvc:Axis.Separator>
                <lvc:Separator Step="1" />
            </lvc:Axis.Separator>
        </lvc:Axis>
    </lvc:AxesCollection>
</lvc:CartesianChart.AxisX>


来源:https://stackoverflow.com/questions/48315993/livecharts-not-displaying-label-on-x-axis-in-wpf

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!