little jules

Hi

I am looking for a way to plot several timeseries using different views (for instance lines, or histograms and so on). Typically, data can be one of

- a line (a series of X, Y points)

- a series of OHLC Candles (X=timestamp, Y=(...))

- a bubble map (X, Y, Diameter)

Since several view can appear on the same map, it means that different types of views (inheriting from the same base class) are plotted, but that their item template varies.

The expected code should be something like:

plotCurves.Add(new LineCurve(...)); //which adds a LineCurve object to plotCurves._curves

plotCurves.Add(new OHLCCandleCurve(...));

...

plotCurves.Curves returns all curves as a 2DCurve collection where a 2DCurve is simply a curve with X and Y coordinates.

I was thinking about using the following but was wondering if there was a preferred way to do it...


<!-- Timeseries container -->
<ListBox x.Name="plotCurves" ItemsSource="{TemplateBinding Path=Curves}" Background="White">
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<Canvas Background="Transparent" />
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
</ListBox>

<DataTemplate DataType="{x:Type local:LineCurve}">
<Polygon Points="{TemplateBinding Path=Points, Converter={StaticResource LineCurveCoordinatesConverter}}"/>
</DataTemplate>

<DataTemplate DataType="{x:Type localSurpriseHLCCandleCurve}">
<ListBox>

<ListBox.ItemsSource>
<TemplateBinding Path="Points"/>
</ListBox.ItemsSource>

<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<Canvas Background="Transparent" />
</ItemsPanelTemplate>
</ListBox.ItemsPanel>

<ListBox.ItemTemplate>
<DataTemplate>
<Border
Canvas.Left="{Binding Path=Timestamp, Converter={StaticResource OHLCCandleConvertTimestampToX}}"
Canvas.Bottom="{Binding Path=Timestamp, Converter={StaticResource OHLCCandleConvertTimestampToY}}"
>
<!-- Rest of the template here... -->
</Border>
</DataTemplate>
</ListBox.ItemTemplate>

</ListBox>
</DataTemplate>

Thank you very much for your help and insight