Pre loader

Tag: XAML

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

0 votes
18k views

Hi,

i’d like to style my major and minor grid lines so that they are not visible over the whole width of the chart but only in the center.
I tried to asign them a LinearGradientBrush, but that did not show the Gridline at all, clipping did not change anything on the visual appearance of the Gridlines. Are these stylings not supported for grid lines?

My styling of grid lines and axes look as the following:

<Setter Property="MajorGridLineStyle">
    <Setter.Value>
        <Style TargetType="{x:Type Line}">
            <Setter Property="Stroke" Value="DarkRed" />
            <Setter Property="StrokeThickness" Value="1" />
        </Style>
    </Setter.Value>
</Setter>
<Setter Property="MinorGridLineStyle">
    <Setter.Value>
        <Style TargetType="{x:Type Line}">
            <Setter Property="Stroke" Value="Gray" />
            <Setter Property="StrokeThickness" Value="1" />
        </Style>
    </Setter.Value>
</Setter>
...
<s:SciChartSurface.XAxis>
            <s:NumericAxis VisibleRange="{Binding ScaleBarRange}"
                           FlowDirection="RightToLeft"
                           MajorDelta="5"
                           DrawMajorGridLines="True"
                           MinorDelta="1"
                           DrawMinorGridLines="True"
                           Style="{StaticResource ScaleStyle}">
            </s:NumericAxis>
        </s:SciChartSurface.XAxis>
        <s:SciChartSurface.YAxis>
            <s:NumericAxis Visibility="Collapsed"
                           DrawMajorGridLines="False" />
        </s:SciChartSurface.YAxis>

I attached an image that shows approximately how i’d like it to be and i already have a workaround using two surfaces overlayed over each other, but that one i’d really like to get rid of.
I’d be thankful for a hint that allows me to individually crop/clip grid lines.

Thanks,
Martin

0 votes
0 answers
15k views

Hello,
I’m developing the WPF charts application in C#. I have an activated developer license.
When I compile my code with DUBUG mode, XamlParseException occurred. (In release mode, there are no exception)

That only happened in my new SciChart project, old one never happened.
I already reference the library like SciChart.Charting and the runtime license key is included in App.xaml.cs.

0 votes
13k views

I’m trying to change the AutoRange property of my axis in a VisualStateManager storyboard and it’s throwing an exception saying the value is invalid. Is this not possible or should the object/property be accessed differently?

Exception: “The animation(s) applied to the ‘AutoRange’ property calculate a current value of ‘AutoRange.Once’, which is not a valid value for the property.”

<Storyboard>
<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="AutoRange" Storyboard.TargetName="XAxis">
<DiscreteObjectKeyFrame KeyTime="0" Value="AutoRange.Once"/>
</ObjectAnimationUsingKeyFrames>
</Storyboard>
.
.
.
<sc:NumericAxis x:Name="XAxis" AxisTitle="Time (s)" TitleFontSize="14" AutoRange="Always"/>

Thanks!

0 votes
10k views

Hello,

I would like to use the RolloverModifier to display a given datapoint’s identification (string) metadata. The solution suggested in this link on correlating metadata to datapoints seems promising, but for the fact that I have multiple charts to display simultaneously, hence I need multiple lookup arrays. I originally thought to use a ValueConverter that would manage lookup of the identification value based a chart view model instance code (ChartId) and the index provided in the XyzDataSeries. As control charts are instantiated, they register with the ValueConverter, which maintains a static lookup dictionary. In the XAML, the ZValue is passed as the value and the chartID is passed as a parameter to the ValueConverter. I have run into a couple key challenges, however:

  1. ConverterParameters cannot be bound; hence I cannot bind to the ChartId, whether it is stored in a viewmodel or in a different XAML element.
  2. WPF does not allow use of nested value converters in XAML; this prevents me from nesting the ValueConverter within the chart view model (where reference to the ChartId is readily available).

I’m exploring some other options, but they are getting ugly fast, so I figured it’s time to ask for assistance. Is there another way to do this (desirably adhering to MVVM practices)?

Key excerpts of my code are pasted below:

Surface:

<TextBlock x:Name="ChartIdBlock" IsEnabled="False" Text="{Binding ChartId}"/>
<s:SciChartSurface x:Name="ScsControlChart" MinHeight="200" s:ThemeManager.Theme="BlackSteel">
<s:SciChartSurface.RenderableSeries>
    <s:FastLineRenderableSeries x:Name="Data" SeriesColor="White" DataSeries="{Binding Chart, Converter={StaticResource ChartDataToDataSeriesConverter}}" IsSelected="True"/>
   <!-- More data series in same chart -->
</s:SciChartSurface.RenderableSeries>
<s:SciChartSurface.XAxis>
    <s:DateTimeAxis  VisibleRange="{Binding XRange, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}" TickLabelStyle="{StaticResource AxisLabelStyle}" />
</s:SciChartSurface.XAxis>
<s:SciChartSurface.YAxis>
    <s:NumericAxis DrawMajorBands="True" VisibleRange="{Binding YRange, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}" TickLabelStyle="{StaticResource AxisLabelStyle}"/>
</s:SciChartSurface.YAxis>
<s:SciChartSurface.ChartModifier>
    <s:ModifierGroup>
        <s:RolloverModifier x:Name="RolloverModifier" DrawVerticalLine="True" SourceMode="SelectedSeries" TooltipLabelTemplate="{StaticResource RolloverLabelTemplate}"/>
    </s:ModifierGroup>
</s:SciChartSurface.ChartModifier>

RolloverLabelTemplate:

<ControlTemplate x:Key="RolloverLabelTemplate" TargetType="s:TemplatableControl">
    <Border Grid.Row="1" HorizontalAlignment="Left" VerticalAlignment="Top" Background="#77FFFFFF" BorderBrush="#55000000" BorderThickness="1" Padding="5">
        <ItemsControl ItemsSource="{Binding ElementName=RolloverModifier, Path=SeriesData.SeriesInfo}">
            <ItemsControl.ItemTemplate>
                <DataTemplate>
                        <StackPanel Grid.Column="2" Orientation="Horizontal" Margin="3,3,20,3">
                            <TextBlock FontSize="13" FontWeight="Bold" Foreground="{Binding SeriesColor, Converter={StaticResource ColorToBrushConverter}}"
                                       Text="{Binding ZValue, Converter={StaticResource IndexToIdConverter}, ConverterParameter={Binding ElementName=ChartIdBlock, Path=Text}}"/>
                        </StackPanel>
                </DataTemplate>
            </ItemsControl.ItemTemplate>
        </ItemsControl>
    </Border>

Value Converter:

public sealed class ChartIndexToIdConverter : IValueConverter
{
    private readonly static Dictionary<int, Tuple<int, string[]>> _lookup = new Dictionary<int, Tuple<int, string[]>>();
    private readonly static Random _rnd = new Random();

    public static int Register(IControlChart chart)
    {
        var key = _rnd.Next();
        while (_lookup.ContainsKey(key)) key = _rnd.Next();
        _lookup.Add(key, new Tuple<int, string[]>(chart.First().Index, chart.Select(d => d.Id).ToArray()));
        return key;
    }

    public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
    {
        if (value == null) throw new ArgumentNullException("value");
        if (parameter == null) throw new ArgumentNullException("parameter");
        var tuple = _lookup[(int)parameter];
        return tuple.Item2[(int)value - tuple.Item1];
    }
}
0 votes
5k views

Hello,

I’m relatively new to SciChart and I’m facing a challenge with customizing the appearance of a dynamically created series that is bound to a SciChartSurface using SeriesBinding in WPF.

I have a VerticalSliceModifier in my XAML where I define a VerticalLineAnnotation. My series is created in code as a MountainRenderableSeriesViewModel and then bound to the chart using SeriesBinding. Here’s the relevant code snippets:

<s:SciChartSurface
    Grid.Row="1"
    Background="Transparent"
    BorderThickness="0"
    RenderableSeries="{s:SeriesBinding Series}"
    Annotations="{s:AnnotationsBinding Annotations}">

    <s:VerticalSliceModifier ShowTooltipOn="Never" Foreground="White" Name="sliceModifier">
        <s:VerticalSliceModifier.VerticalLines>
            <s:VerticalLineAnnotation X1="{Binding Number}" Style="{StaticResource sliceStyle}" />
        </s:VerticalSliceModifier.VerticalLines>
    </s:VerticalSliceModifier>

</s:SciChartSurface>


public class MountainRenderableSeriesViewModel
{
    public DataSeriesViewModel<double, double> DataSeries { get; set; }
    public DataTemplate RolloverMarkerTemplate { get; set; }
    // Other properties...

    public MountainRenderableSeriesViewModel()
    {
        // Initialize your DataSeries and other properties

        // Set the RolloverMarkerTemplate for this series
        RolloverMarkerTemplate = Application.Current.Resources["CustomRolloverMarkerTemplate"] as DataTemplate;
    }
}

My challenge is that I want to customize the RolloverMarkerTemplate for this dynamically created series. Most of the examples I’ve found show how to use RolloverMarkerTemplate with a statically defined series, but I cannot figure out how to assign it when the series is created in a ViewModel and bound to the chart using SeriesBinding.

Any guidance or code examples on how to achieve this customization would be greatly appreciated.

Showing 5 results

Try SciChart Today

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

Start TrialCase Studies