user3387691
user3387691

Reputation: 11

Livecharts not displaying Label on x axis in WPF

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

Image of the Output

Upvotes: 1

Views: 5658

Answers (1)

Yvonnila
Yvonnila

Reputation: 646

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>

Upvotes: 4

Related Questions