SciChart® the market leader in Fast WPF Charts, WPF 3D Charts, and now iOS Charting & Android Chart Components

Welcome to the SciChart Community Forums!

Please use the forums below to ask questions about SciChart. Take a moment to read our Question asking guidelines on how to ask a good question and our support policy

We also have a tag=SciChart on Stackoverflow.com where you can earn rep for your questions!

0
0

I’m trying to create a context menu that has the menu items ‘Copy’ and ‘Save Image As…’. In my ChartView.xaml, I created a SciChartSurface.ContextMenu and an event handler in the Code Behind. CopyImageToClipBoard(object sender, RoutedEventArgs e) calls sciChartSurface.ExportBitmapToClipboard() that was defined in the class ‘SciChartSurfaceExtensions.cs’. I’ve read the tutorial: http://www.scichart.com/screenshots-xps-printing-x-axis-text-labels and the suggested approach works for a single chart. But how do I implement this with a collection of charts?
Would I have to append all the chart images into one large image first?
How can I get these commands to copy all the charts in my window or save all the charts in my window to an image file?

..and just out of curiosity, how can I pass the sciChartSurface object from XAML to a ViewModel?

Thanks!

Attachments
  • You must to post comments
0
0

Hm.. hope we’ve got it all correctly.

We would suggest modifying a code from the tutorial in such a way that it renders the Panel inside which the Surfaces are located. If you need a hand with that don’t hesitate to ask.

Besides, this forum talk on Context menu can be of some help to you.

Good luck with that and tell us if this helps you!

  • SciChart Team
  • johnnyp112
    Hi, I've been struggling with two main issues with my application and I think I've exhausted my resources so I'm hoping someone can help me.Issue 1: 'Copy' and 'Save Image As...' In my ChartView.xaml, I created a SciChartSurface.ContextMenu and an event handler in the Code Behind. CopyImageToClipBoard(object sender, RoutedEventArgs e) calls sciChartSurface.ExportBitmapToClipboard() that was defined in the class 'SciChartSurfaceExtensions.cs'.These functions work for a single chart but how can I get these commands to copy all the charts in my window or save all the charts in my window to an image file?Out of curiosity, how can I pass the sciChartSurface object from XAML to a ViewModel?Issue 2: Zoom History - the ability to restore a previous visible range. I tried to use Caliburn.Micro Event Aggregator to send a message from my extended RubberBandXyZoomModifierEx to my ShellViewModel (ShellView is the parent View that holds multiple ChartViews) but the message is not properly sent. This is more of an issue with Caliburn.Micro.I have a property called 'SharedXVisibleRange' that all charts in the ShellViewModel bind to.I notice SciChart has an EventAggregator Property. Can I use this instead? If so, how do I use it? Do you have any other suggestions on how I can successfully implement the zoom history?I also looked at this post: http://www.scichart.com/forums/topic/mvvm-dynamic-line-drawing/page/2/ But I was unable to use it since I could not figure out how they passed an instance of their ViewModel into their extended RubberBandXyZoomModifier.
    public customRubberBandXyZoomModifier(AnalogueChartViewModel parent)
    {
        _parent = parent;
    }
    
    Can you please take a look at my sample code and give me some suggestions? Please let me know if I am way off with my implementation. I'm still a newbie. =)The controls are: Right-click: context menu Left-click: drag to zoom Left-click + Ctrl: panThanks in advanced!Johnny
  • You must to post comments
0
0

Hi Johnny,

I think you should change the code which creates bitmap from SciChartSurface in such a way that it would create bitmap from your Panel(or any FrameworkElement) in which charts are placed rather than from single SciChartSurface. Please, use search google for this, it is quite common task so there are lots of existing implementations. Does this make sense for you?

Passing visual components to VM isn’t widely used approach, because it is a violation of MVVM. But as long as you “injects” them via interface, I think it is OK. Please, take a look at this article about MiVVM for more info.

Regarding zoom history, please, take a look at this post, where one of our customers kindly shared his own implementation. Probably it will be useful for you, at least to start with.

To pass VM instance into constructor, you can use either binding or just passing it during modifier construction(in the VM).

Hope this helps!

Best regards,
Yuriy

  • You must to post comments
Showing 2 results
Your Answer

Please first to submit.