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

0 votes

I am trying to bind from my ViewModel to the DataSeries of a ScatterRenderableSeries3D, but no data is showing.

I am binding in this way:

My ViewModel has a property of type ObservableCollection<XyzDataSeries3D<DateTime, double, int>>. I can populate ChartItems, and see the data in it. The property is being notified of change as expected.

If I populate the DataSeries directly from code behind, it works, but not when being bound.

What am I doing wrong?

0 votes

I have implemented two custom themes for use when viewing charts on screen versus printing. Unfortunately, the themes do not contain all necessary color definitions. For example, these are multi-series charts, with each series having a different color. Is there any way to extend the ThemeManager to include these additional required brushes (and of course, be able to bind to those colors from XAML).

Alternatively, if there is a way to bind to existing ThemeManager colors from XAML, i could simply use several existing but otherwise unused ThemeManager brushes for my various series stroke brushes.


0 votes

I did modify this CustomAnnotationChartModifier. I added a databinding to bing the ShowLabelProperty to the IsSelectedProperty.

    // Recreate all annotations, called when LabelsSource property changes or when the
    // CustomAnnotationChartModifier is attached to the parent surface
    private void RebuildAnnotations() {
        if (base.ParentSurface == null || LabelsSource == null)
        var annotationCollection = base.ParentSurface.Annotations;
        foreach (var item in LabelsSource) {
            var vla = new VerticalLineAnnotation();
            vla.DataContext = item;
            vla.SetBinding(AnnotationBase.X1Property, new Binding("X1") { Mode = BindingMode.OneWay });
            // bind ShowLabelProperty
                new Binding("IsSelected") { RelativeSource = RelativeSource.Self, Mode=BindingMode.OneWay });
            vla.IsEditable = this.IsEditable;
            // after manipulation: write X1Property back to Viewmodel 
            vla.DragEnded += Annotation_DragEnded;
            vla.LabelPlacement = LabelPlacement.Top;
            // test to set directly ShowLabel = (bool)e.NewValue;
            //vla.Unselected += annotation_SelectionChanged;
            //vla.Selected += annotation_SelectionChanged; 
            if (this.MarkerManipulatedCommand != null)
                vla.ManipulationCompleted += new EventHandler<ManipulationCompletedEventArgs>(manipulationCompleted_EventHandler);

    private void annotation_SelectionChanged(object sender, EventArgs e) {
        var vla = sender as VerticalLineAnnotation;
        if (vla == null) return;
        vla.ShowLabel =vla.IsSelected;

Result: Select the annoation will show the label. Unselect will not remove the label.
I did try the unselected and selected-event to do the same on other way ->same result.
I can see also that each new selection lighter the label (is it shown more than one time?).

How can I add ToolTipLabel inside that CustomAnnotationChartModifier to see the y-values?


1 vote

I want to put multiple Line Charts on a standard WPF TabControl. One Chart per tab.
Each tab should show a different chart with, in general, a different range on its X axis.
After a chart on a tab has been panned or zoomed, then after switching to another tab and then returning to the original tab, then the original X axis values should be preserved.
My problem is that I end up with a behaviour that looks like all the charts share one X axis.

So my question is how can I achieve the desired behaviour?
I did try databinding XAxis and, later, XAxes, but I ended up with the same behaviour.
Thanks in advance to anyone that can help me out with this.

Here is the briefest example I could construct that displays the problem.
It simply displays 3 tabs with different ranges of X values and AutoRange set to “Once”.
When it runs, all 3 charts are displayed with the same X axis range which is only correctly autoranged for the first tab.
The attached images are screenshots of the three tabs.

Here is my XAML:

    xmlns:local="clr-namespace:SciTest" xmlns:s="" x:Class="SciTest.MainWindow"
    Title="MainWindow" Height="300  " Width="500">

    <TabControl ItemsSource="{Binding}">
            <!--This dictates what goes in the Tab header-->
                <TextBlock Text="{Binding Title}" />
            <!--This dictates what goes in the tab page-->
                <s:SciChartSurface RenderableSeries="{Binding RSeries}">
                        <s:NumericAxis AutoRange="Always"/>

And here is the code-behind for the Data Context

    class RSeriesSource
    public String Title { get; set; }
    public ObservableCollection<IRenderableSeries> RSeries{get;set;}
    static Random rnd = new Random(); //for generating example data
    public RSeriesSource()
        RSeries = new ObservableCollection<IRenderableSeries>();
    public static RSeriesSource Example(int n)
        RSeriesSource res = new RSeriesSource();
        res.Title = "S" + n.ToString();
        return res;

    FastLineRenderableSeries AddRS(int offset)
        XyDataSeries<Double, Double> Series = new XyDataSeries<Double, Double>();
        for (int ix = 0; ix < 10; ix++)
            Series.Append(offset * 5 + ix, offset + rnd.NextDouble());
        FastLineRenderableSeries res = new FastLineRenderableSeries();
        res.DataSeries = Series;
        //if (yAx != null)
        //    res.YAxisId = yAx.Id; //Use the Id NOT the axis
        return res;

class RSeriesSourceList : ObservableCollection<RSeriesSource>
    public RSeriesSourceList()
        for (int i = 0; i < 3; i++)
            Add( RSeriesSource.Example(i));
0 votes

I have the following xaml code for HorizontalLineAnnotations. I have a viewmodel with simple properties for WasteMaxValue etc.
I don’t get any binding errors. Sometimes everything works as expected when I start up. Sometimes the lines show up but they wont follow when I resize the view (and the graph). Sometimes the lines don’t show up at all.
If I do a very fast “pan” with the mouse so that the graph data moves outside the graph, the lines show up and they follow when I resize the view and the graph. Have you experienced this before? Is it an obvious error?

                <s:HorizontalLineAnnotation HorizontalAlignment="Stretch" 
                    Y1="{Binding WasteMaxValue}" Stroke="Red" StrokeThickness="2">
                <s:HorizontalLineAnnotation HorizontalAlignment="Stretch" 
                    Y1="{Binding WasteMinValue}" Stroke="Red" StrokeThickness="2">
                <s:HorizontalLineAnnotation HorizontalAlignment="Stretch" 
                    Y1="{Binding WarningMaxValue}" Stroke="Yellow" StrokeThickness="2">
                <s:HorizontalLineAnnotation HorizontalAlignment="Stretch" 
                    Y1="{Binding WarningMinValue}" Stroke="Yellow" StrokeThickness="2">
                <s:HorizontalLineAnnotation HorizontalAlignment="Stretch" 
                    Y1="{Binding SetValue}" Stroke="Green" StrokeThickness="2">
0 votes

I would like a “Pause” button on my chart to temporarily suspend drawing updates, even while realtime data updates are still coming in to the databound DataSeries. Pressing the button again would re-enable drawing updates and show the data lines updated with all the data collected while drawing was previously paused.

Is there anything in the SciChart API to do this easily or would I need to do this manually (possibly by cloning the DataSeries when the chart is paused and databinding to the clones, then restoring the original binding when un-paused)?


0 votes

I am directly editing my XyDataSeries on a chart by using my mouse. As the mouse moves I edit either the x or y value of a point using the methods

    public void SetPointYValueAt(IDataSeries series, int index, double newValue)
        series.YValues[index] = newValue;

    public void SetPointXValueAt(IDataSeries series, int index, double newValue, double xMin, double xMax)
        var xValue = newValue;

        // limit x values to keep them sorted
        if (xValue < xMin) xValue = xMin;
        if (xValue > xMax) xValue = xMax;
        series.XValues[index] = xValue;


With this code I am not getting an update at my ViewModel:

    public IDataSeries<double, double> MyDataSeries
        get { return _myDataSeries; }
            _myDataSeries = value;

Here is my XAML:

            <sciChartExtensions:StepLineRenderableSeries x:Name="HResitivitySeries" IsDigitalLine="True" DataSeries="{Binding MyDataSeries, Mode=TwoWay}">

Where StepLineRenderableSeries is derived from FastLineRenderableSeries with IsDigitalLine = true and the HitTest method overridden.

How can I get MyDataSeries to update?

1 vote


I have a surface with multiple dataseries in it. I have a legend for each serie, setup like this:

chart.ChartModifier = new Abt.Controls.SciChart.ChartModifiers.LegendModifier() { Name = "legendModifier" };

var legend = new Abt.Controls.SciChart.Visuals.SciChartLegend { Margin = new Thickness(5) };

// Bind the legend to the data source
var legendDataBinding = new Binding("LegendData") { Source = chart.ChartModifier };
legend.SetBinding(Abt.Controls.SciChart.Visuals.SciChartLegend.LegendDataProperty, legendDataBinding);

And it works fine.
However, I would also like to bind the visibility of the legends to the visibility of the dataseries. I have tried this:

// Bind the legend visibility to the data source
var legendVisibilityBinding = new Binding("Visibility") 
    Converter = new BoolToVisibilityConverter(),
    Source = line.IsVisible
legend.SetBinding(Abt.Controls.SciChart.Visuals.SciChartLegend.LegendDataProperty, legendVisibilityBinding);

But it doesn’t seem to work, any suggestions, anyone?


  • JacobB asked 3 years ago
  • last active 3 years ago
Showing 8 results
This template supports the sidebar's widgets. Add one or use Full Width layout.