Pre loader

Chart on BoxAnnotation so that BoxAnnotation act as parent container.

Welcome to the SciChart Forums!

  • Please read our Question Asking Guidelines for how to format a good question
  • Some reputation is required to post answers. Get up-voted to avoid the spam filter!
  • We welcome community answers and upvotes. Every Q&A improves SciChart for everyone

WPF Forums | JavaScript Forums | Android Forums | iOS Forums

1
0

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.

Images
  • You must to post comments
0
1

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

  • sonu91@gmail.com
    Hi Andrew,Thanks for your quick response, I am trying to do the requirement according to the given solution but I am getting "Unable to Apply the Control Template. PART_BoxAnnotationRoot is missing or of the wrong type" error. As it given for xaml file but I need to implement in viewModel,Plz help
  • sonu91@gmail.com
    Hi Andrew, Can I get the same xaml code as a C# code ,So That I can test in Viewmodel.I hope it will work.
  • Andrew Burnett-Thompson
    Oh sorry, I have edited my code in answer. Try adding x:Name="PART_BoxAnnotationRoot" to the Border. To do the same in Code-behind would be nearly impossible, I would strongly recommend altering control templates in Xaml! However, if you wanted to go this route you can use this technique: http://stackoverflow.com/a/17595059/303612
  • sonu91@gmail.com
    Thak you Andrew,Yes I had added the same & It was working in xaml code, But I have to make it dynymic at ViewModel side,let me try the other solution.
  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.

Try SciChart Today

Start a trial and discover why we are the choice
of demanding developers worldwide

Start TrialCase Studies