SciChart® the market leader in Fast WPF Charts, WPF 3D Charts, and iOS Chart & 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!

Please note: SciChart team will only answer questions from customers with active support subscriptions. Expired support questions will be ignored. If your support status shows incorrectly, contact us and we will be glad to help.

0
0

Is there a way to define the RolloverMarkerTemplate from the code, or to change the rollover marker dynamically?

Alternatively, is there a way to define a set of series and rollover marker templates in a declarative way (from the XAML) and use them when I dynamically create the series, in a MVVM way of course…

For example, I would like to define, let’s say 10 different types of point markers with different colors, and when I add a new data serie, make it take the first one, then the next the second and so on until it loops.

  • You must to post comments
0
0

Yes you can,

To change the RolloverMarkerTemplate for a specific series, use this code

<!--  Style for a RenderableSeries -->
<Style x:Key="ARenderableSeriesStyle" TargetType="s:BaseRenderableSeries">
    <Setter Property="RolloverMarkerTemplate">
        <Setter.Value>
            <ControlTemplate>
                <Ellipse Width="9"
                        Height="9"
                     Fill="#FF52CC54"
                     Stroke="White"
                     StrokeThickness="2" />
            </ControlTemplate>
        </Setter.Value>
    </Setter>
</Style>

How to change these in MVVM? Well, I would suggest creating an attached property (inheriting FrameworkElement) which has DependencyPropeties on it for your various rollover marker styles, then binding that to a ViewModel to switch them, e.g. (in pseudocode)

class RolloverMarkerSwitcher : FrameworkElement
– DependencyProperty FirstMarkerTemplateProperty
– DependencyProperty SecondMarkerTemplateProperty
– AttachedProperty ChooseMarkerProperty // e.g. enum First, Second

Then in XAML

<s:XyScatterRenderableSeries local:RolloverMarkerSwitcher.ChooseMarker="{Binding WhichMarkerToChoose}"/>

Hope this has given you an idea how to proceed!

Andrew

  • xhahn
    Hello Andrew, I'm sorry, I took some time to try and understand your answer, but there's probably something I miss, because I don't understand it. What I'd like to do: - I have an unknown (dynamic) number of series - All those series are scatter series - Each series should have its own color and point marker type (cross, square, triangle, ellipse) What I did for now: - I create a XYDataSeries and a XyScatterRenderableSeries from the ViewModel, I set the SeriesColor of the renderSerie to a specific color - I create a ChartSeriesViewModel linking both the data series and the render series - I add the ChartSeriesViewModel to a collection that is binded to my sciChartSurface How I would like to do it: - I would like to define the XyScatterRenderableSeries (or at least its style) from the XAML (it's UI design stuff, so it shouldn't be in the ViewModel IMO) - Make the color and point marker "dynamic", each new series would have a new combination of color and point marker - Create a collection of XyDataSeries as a property of the ViewModel that the view will bind to Not sure if that is possible? I have the impression that the example you gave in the previous code does the opposite of what I'm trying to achieve.
  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.