简体   繁体   中英

Stacked Charts in modern UI Metro WPF

Can someone explain to me how to create a stacked bar graph using Morder UI (Metro) Charts ( http://modernuicharts.codeplex.com/ ) in wpf.

if I do the following XAML;

 <metroChart:StackedBar100Chart d:IsLocked="True" Name="f" >
                <metroChart:StackedBar100Chart.Series>
                    <metroChart:ChartSeries  DisplayMember="Name"
                        ItemsSource="{Binding ExampleValues}"
                        ValueMember="Count" />
                </metroChart:StackedBar100Chart.Series>
  </metroChart:StackedBar100Chart>

I can bind to an observable collection of numbers - however how do i add a second stack, third stack etc..

Adding a new series adds more bars;

 <metroChart:StackedBar100Chart d:IsLocked="True">
                    <metroChart:StackedBar100Chart.Series>
                        <metroChart:ChartSeries  DisplayMember="Name"
                            ItemsSource="{Binding ExampleValues}"
                            ValueMember="Count" />
                        <metroChart:ChartSeries  DisplayMember="Name"
                            ItemsSource="{Binding ExampleValues2}"
                            ValueMember="Count" />
                    </metroChart:StackedBar100Chart.Series>
  </metroChart:StackedBar100Chart>

 exampleValues.Add(new ExampleValues() { Name = "China", Count = 1340 });
        exampleValues.Add(new ExampleValues() { Name = "India", Count = 1220 });
        exampleValues.Add(new ExampleValues() { Name = "United States", Count = 309 });
        exampleValues.Add(new ExampleValues() { Name = "Indonesia", Count = 240 });
        exampleValues.Add(new ExampleValues() { Name = "Brazil", Count = 195 });
        exampleValues.Add(new ExampleValues() { Name = "Pakistan", Count = 174 });
        exampleValues.Add(new ExampleValues() { Name = "Nigeria", Count = 158 });

        exampleValues2.Add(new ExampleValues() { Name = "England", Count = 860 });
        exampleValues2.Add(new ExampleValues() { Name = "Scotland", Count = 600 });
        exampleValues2.Add(new ExampleValues() { Name = "Wales", Count = 209 });

在此处输入图片说明

how do I stack on top of an existing bar?

What I want to produce is something like this for each example country;

在此处输入图片说明

The Series element is a collection, so you can just add another ChartSeries :

<metroChart:StackedBar100Chart.Series>
    <metroChart:ChartSeries DisplayMember="Name"
                            ItemsSource="{Binding ExampleValues}"
                            ValueMember="Count" />

    <!-- You can add more series elements here. -->
    <metroChart:ChartSeries DisplayMember="Name"
                            ItemsSource="{Binding AnotherCollection}"
                            ValueMember="Count" />
</metroChart:StackedBar100Chart.Series>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM