实时图表未在WPF中的x轴上显示标签 [英] Livecharts not displaying Label on x axis in WPF

查看:192
本文介绍了实时图表未在WPF中的x轴上显示标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在活动图表中显示数据,并且Label值已绑定(在调试中可见).但是以某种方式在用户界面中,它显示的是一个或两个值,而不是后端字符串数组中的所有值.

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代码:

Model.cs Code:

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

ModelViewCode.cs

ModelViewCode.cs

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

XAML:

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

屏幕截图

推荐答案

像这样为您的轴定义一个AxisSeparator,并将其Step属性设置为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>

这篇关于实时图表未在WPF中的x轴上显示标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆