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

1 vote
259 views

Hi

I have multiple SciChartSurfaces aligned using the HorizontalGroupHelper. I also need to have multiple y-axes in the charts. I was hoping to use set the margin on each y-axis, but when I do, the upper axis is drawn outside the window. Is there a work-around?

Example.

<Window x:Class="ScichartTest.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:s="http://schemas.abtsoftware.co.uk/scichart"
Title="MainWindow"
Width="800"
Height="450">

<Grid>
    <Grid.ColumnDefinitions>
        <ColumnDefinition />
        <ColumnDefinition />
    </Grid.ColumnDefinitions>

    <!--  Chart left  -->
    <s:SciChartSurface s:HorizontalGroupHelper.HorizontalChartGroup="group">

        <s:SciChartSurface.XAxis>
            <s:NumericAxis
                AxisAlignment="Left"
                AxisTitle="x" />
        </s:SciChartSurface.XAxis>

        <s:SciChartSurface.YAxes>
            <s:NumericAxis
                Margin="0,0,0,12"
                AxisAlignment="Top"
                AxisTitle="Left y1"
                Id="LeftY1" />
            <s:NumericAxis
                Margin="0,0,0,12"
                AxisAlignment="Top"
                AxisTitle="Left y2"
                Id="Lefty2" />
            <s:NumericAxis
                Margin="0,0,0,12"
                AxisAlignment="Top"
                AxisTitle="Left y3"
                Id="LeftY3" />
        </s:SciChartSurface.YAxes>

    </s:SciChartSurface>

    <!--  Chart right  -->
    <s:SciChartSurface
        Grid.Column="1"
        s:HorizontalGroupHelper.HorizontalChartGroup="group">

        <s:SciChartSurface.XAxis>
            <s:NumericAxis
                AxisAlignment="Left"
                AxisTitle="x" />
        </s:SciChartSurface.XAxis>

        <s:SciChartSurface.YAxes>
            <s:NumericAxis
                AxisAlignment="Top"
                AxisTitle="Right y1"
                Id="RightY1" />
        </s:SciChartSurface.YAxes>

    </s:SciChartSurface>

</Grid>

enter image description here

2 votes
6k views

Hi

This is a little snippet of my code

<s:SciChartSurface SeriesSource="{Binding ChartSeries}"
                   YAxes="{Binding YAxisCollection}"
                   XAxis="{Binding XAxis}"
                   Annotations="{Binding AnnotationCollection}"
                   s:HorizontalGroupHelper.HorizontalChartGroup="horizontalChartGroup">

I would like to be able to set throught my ViewModel the “syncWidthGroup” of the HorizontalChartGroup like this.

s:HorizontalGroupHelper.HorizontalChartGroup="{Binding ChartGroup}"

But an exception is thrown saying I can only bind to DP og DO.

    System.Windows.Markup.XamlParseException occurred
  HResult=-2146233087
  Message=A 'Binding' cannot be set on the 'SetHorizontalChartGroup' property of type 'SciChartSurface'. A 'Binding' can only be set on a DependencyProperty of a DependencyObject.
  Source=PresentationFramework
  LineNumber=14
  LinePosition=324
  StackTrace:
       at System.Windows.Markup.WpfXamlLoader.Load(XamlReader xamlReader, IXamlObjectWriterFactory writerFactory, Boolean skipJournaledProperties, Object rootObject, XamlObjectWriterSettings settings, Uri baseUri)
       at System.Windows.Markup.WpfXamlLoader.LoadBaml(XamlReader xamlReader, Boolean skipJournaledProperties, Object rootObject, XamlAccessLevel accessLevel, Uri baseUri)
       at System.Windows.Markup.XamlReader.LoadBaml(Stream stream, ParserContext parserContext, Object parent, Boolean closeStream)
       at System.Windows.Application.LoadComponent(Object component, Uri resourceLocator)
       at Sekal.DrillScene.Desktop.Application.Views.TrackView.InitializeComponent() in c:\dev\projects\SekalApplications\Client\Sekal.DrillScene.Desktop\obj\Debug\decoratedxaml\Application\Views\TrackView.xaml:line 1
       at Sekal.DrillScene.Desktop.Application.Views.TrackView..ctor() in c:\dev\projects\SekalApplications\Client\Sekal.DrillScene.Desktop\Application\Views\TrackView.xaml.cs:line 10
  InnerException: 

So how would I go about doing this through code and not xaml, as I use ViewModel first approach and ViewModels are dynamically appended to an Items collection? (Using Caliburn.Micro)

Showing 2 results
This template supports the sidebar's widgets. Add one or use Full Width layout.