SciChart® the market leader in Fast WPF Charts, WPF 3D Charts, and now iOS Charting & Android Chart Components
Hi
I want to plot line chart on BoxAnnotation, so that BoxAnnotion become as a container.
i.e dataSeries.Append(100, 100);
dataSeries.Append(200, 150;
on BoxAnnotation
Please have a lool into the picture.
Hi there,
If I understand correctly, what you want to achieve is to have a chart inside a BoxAnnotation, so you can drag this around the underlying chart. Is that correct?
If so, this could be achieved by re-templating the BoxAnnotation ControlTemplate to hold another chart.
The template for BoxAnnotation is quite simple. It specifies a Border with templateBindings to BorderBrush, BorderThickness, Background. Try this, for instance:
<BoxAnnotation> <BoxAnnotation.Template> <!-- Retemplate the BoxAnnotation to be anything you want --> <ControlTemplate TargetType="{x:Type BoxAnnotation}"> <Border x:Name="PART_BoxAnnotationRoot" BorderBrush="{TemplateBinding BorderBrush}" Background="{TemplateBinding Background}" BorderThickness="{TemplateBinding BorderThickness}"> <!-- Place a SciChartSurface inside the BoxAnnotation Border --> <s:SciChartSurface> <s:SciChartSurface.RenderableSeries> <!-- Set DataContext of annotation equal to a ViewModel so you can bind to DataSeries property --> <s:FastLineRenderableSeries DataSeries="{Binding DataSeries}"/> </s:SciChartSurface.RenderableSeries> <s:SciChartSurface.YAxis> <s:NumericAxis/> </s:SciChartSurface.YAxis> <s:SciChartSurface.XAxis> <s:NumericAxis/> </s:SciChartSurface.XAxis> </s:SciChartSurface> </Border> </ControlTemplate> </BoxAnnotation.Template> </BoxAnnotation>
I’ve not tested the above code but it conveys the concept. You can template the BoxAnnotation to be anything you want, even placing a chart inside it. Just beware that you must set the DataContext of your BoxAnnotation equal to something (like a viewmodel) so the inner ScichartSurface can see this datacontext to bind to DataSeries.
Let me know if it helps, and post pictures of the result if you achieve it!
Best regards,
Andrew
Please login first to submit.