0

I'm trying to make the WPF Chartplotter work with some WPF MVVM. As a target of my interest I've chosen our TeamCity Tests Performance. The current Plotter is looking like this:

        <dd:ChartPlotter Grid.Row="1">
            <dd:ChartPlotter.HorizontalAxis>
                <dd:HorizontalIntegerAxis />
            </dd:ChartPlotter.HorizontalAxis>
            <dd:ChartPlotter.VerticalAxis>
                <dd:VerticalIntegerAxis/>
            </dd:ChartPlotter.VerticalAxis>

            <dd:VerticalAxisTitle Content="Performance in Minutes" FontSize="10" />
            <dd:HorizontalAxisTitle Content="Build by ID" FontSize="10" />

            <dd:LineGraph DataSource="{Binding TestRunsPerformance, IsAsync=True}" Stroke="Green" StrokeThickness="2">
                <dd:LineGraph.Description>
                    <dd:PenDescription DescriptionString="Test" />
                </dd:LineGraph.Description>
            </dd:LineGraph>

            <dd:LineGraph DataSource="{Binding TestSlowRunsPerformance, IsAsync=True}" Stroke="Red" StrokeThickness="2">
                <dd:LineGraph.Description>
                    <dd:PenDescription DescriptionString="TestSlow" />
                </dd:LineGraph.Description>
            </dd:LineGraph>
        </dd:ChartPlotter>
    </Grid>

So I have basically two Test-Categories and for each I show a LineGraph in the Plotter, which I bind to the EnumerableDataSource in the ViewModel. Unfortunately I couldn't test it, but I'm certain it will work this way, since one LineGraph did work so far. This is cool, but now I would like to make a second Chart with the Unit-Tests with the highest influence. But for this, I can't just create LineGraphs in the XAML and bind, but I would need something like a LineGraph Collection and set an amount of LineGraphs dynamically. Since I'm also learning MVVM, it would be troublesome If I'd really need to do this in the Code behind. Unfortunately, all the Examples I found so far do exactly this, for example: Dynamic Line chart in C# WPF Application

I found also examples to make this work for Canvas: Is it possible to bind a Canvas's Children property in XAML? but these are UIElements, not PlotterElements.

Is what I'm trying even possible or am I doing something fundamentally wrong?

Community
  • 1
  • 1
Matthias Müller
  • 3,336
  • 3
  • 33
  • 65
  • I tried some charting libraries for wpf and I did not like them, so Imade this, maybe it helps you too. https://github.com/beto-rodriguez/Live-Charts – bto.rdz Dec 13 '15 at 18:53
  • Thanks, so I guess this supplies dynamically binding multiple Lines? I will for sure give it a try. – Matthias Müller Dec 15 '15 at 11:42

0 Answers0