Duy Anh
Duy Anh

Reputation: 11

ChartControl In WPF

How to add Point to ChartControl in WPF (by Code)

XAML code

<Grid> 
    <dxc:ChartControl> 
        <dxc:ChartControl.Legends> 
            <dxc:Legend/> 
        </dxc:ChartControl.Legends> 
        <dxc:XYDiagram2D> 
            <dxc:BarSideBySideSeries2D DisplayName="Series 1"/> 
        </dxc:XYDiagram2D> 
    </dxc:ChartControl> 
</Grid> 

Upvotes: 0

Views: 467

Answers (2)

dhilmathy
dhilmathy

Reputation: 2868

Try adding the SeriesPoint to Points collection from code behind. Like,

barSeries.Points.Add(new DevExpress.Xpf.Charts.SeriesPoint { Argument = "A", Value = 1 });
barSeries.Points.Add(new DevExpress.Xpf.Charts.SeriesPoint { Argument = "B", Value = 2 });
barSeries.Points.Add(new DevExpress.Xpf.Charts.SeriesPoint { Argument = "C", Value = 3 });

Where, barSeries is your BarSideBySideSeries2D series.

Upvotes: 1

DmitryG
DmitryG

Reputation: 17848

You can add points to a series manually:

...
<dxc:BarSideBySideSeries2D.Points>
    <dxc:SeriesPoint Argument="A" Value="1" />
    <dxc:SeriesPoint Argument="B" Value="2" />
    <dxc:SeriesPoint Argument="C" Value="3" />
    <dxc:SeriesPoint Argument="D" Value="4" />
</dxc:BarSideBySideSeries2D.Points>
...

Here is the full-fledged example.

Take a look at the Providing Data help article for more information.

Upvotes: 0

Related Questions