Pre loader

1

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

Hi Aitkin,

You should try using the LegendModifier, which is demonstrated here:
Legend Modifier Demo

It uses a similar mechanism to bind to SeriesInfo objects as the RolloverModifier. The LegendModifier sets SeriesInfo.XValue equal to the latest value in the data-series. You’ll have to modify the control template of the LegendControl to display the info. So, the Xaml would look something like this (taken from MultipleLinesView.xaml in the examples)

    <Grid>
        
        <SciChart:SciChartSurface x:Name="sciChart" SciChart:ThemeManager.Theme="ExpressionLight">

            <!-- Declare RenderableSeries ... -->

            <!-- Declare Axes ... -->           

            <!-- Declare ChartModifiers -->
            <SciChart:SciChartSurface.ChartModifier>
                <SciChart:ModifierGroup>
                    <SciChart:LegendModifier x:Name="legendModifier"/>
                </SciChart:ModifierGroup>
            </SciChart:SciChartSurface.ChartModifier>

        </SciChart:SciChartSurface>

       <!-- Declare SciChartLegend and override template -->
        <SciChart:SciChartLegend Margin="23,23" LegendData="{Binding LegendData, ElementName=legendModifier}">
            <SciChart:SciChartLegend.Template>
                <ControlTemplate TargetType="SciChart:SciChartLegend">
                    <ControlTemplate.Resources>
                        <Common:IComparableConverter x:Key="ComparableConverter"/>
                        <Common:ColorToBrushConverter x:Key="ColorToBrushConverter"/>
                    </ControlTemplate.Resources>
                    <Border x:Name="PART_Border"
                            HorizontalAlignment="{TemplateBinding HorizontalAlignment}"
                            VerticalAlignment="{TemplateBinding VerticalAlignment}"
                            Background="{TemplateBinding Background}"
                            BorderBrush="{TemplateBinding BorderBrush}"
                            BorderThickness="{TemplateBinding BorderThickness}"
                            Padding="{TemplateBinding Padding}">

                        <ItemsControl BorderThickness="0"
                                      DataContext="{TemplateBinding LegendData}"
                                      ItemsSource="{Binding SeriesInfo}">
                            <ItemsControl.ItemTemplate>
                                <DataTemplate>
                                    <Grid HorizontalAlignment="Left">
                                        <Grid.ColumnDefinitions>
                                            <ColumnDefinition/>
                                            <ColumnDefinition/>
                                            <ColumnDefinition/>
                                            <ColumnDefinition/>
                                        </Grid.ColumnDefinitions>

                                        <Ellipse Fill="{Binding SeriesColor, Converter={StaticResource ColorToBrushConverter}}" Width="9" Height="9" Margin="3"/>

                                        <TextBlock Grid.Column="1" Text="{Binding SeriesName}" Width="90" Style="{StaticResource tbStyle}"/>

                                        <!-- When binding to XValue, YValue of type IComparable, StringFormat is mandatory due to a -->
                                        <!-- XAML bug that cannot convert IComparable to text, even though underlying type is double -->
                                        <StackPanel Orientation="Horizontal" Grid.Column="2">
                                            <TextBlock Text="X: " Style="{StaticResource tbStyle}"/>
                                            <TextBlock Text="{Binding XValue, StringFormat=\{0:0.00\}}" Style="{StaticResource tbStyle}"/>
                                        </StackPanel>
                                        <StackPanel Orientation="Horizontal" Grid.Column="3">
                                            <TextBlock Text="Y: " Margin="3" Style="{StaticResource tbStyle}"/>
                                            <TextBlock Text="{Binding YValue, StringFormat=\{0:0.00\}}" Style="{StaticResource tbStyle}"/>
                                        </StackPanel>

                                    </Grid>
                                </DataTemplate>
                            </ItemsControl.ItemTemplate>
                        </ItemsControl>
                    </Border>
                </ControlTemplate>
            </SciChart:SciChartLegend.Template>
        </SciChart:SciChartLegend>

    </Grid>

The controltemplate basically modifies the existing LegendControl to display the latest YValue after the series name. The StringFormat is needed to convert an IComparable value to double (unfortunately this implicit conversion is lacking in the .NET framework).

This should result in the following (attached image)

Best regards,
Andrew

0 votes
In reply to: How to print a chart?

UPDATED

Hi there,

We have several articles on printing and exporting to bitmap or XPS/PDF etc…

Please see:

The Screenshots, XPS Printing, X-Axis Text Labels article now has an updated sample which compiles against SciChart v3.0 so you can download it and get started.

Hope this helps!
Yuriy

0 votes
In reply to: Candle width

Hello there,

Unfortunately, you cannot change a width of candles in series: it is calculated internally based on amount of points on screen. ActualWidth and Width properties which you have mentioned are just inherited from base class(Control), and they are ignored because all series are rendered as bitmaps.

Please, don’t hesitate to ask questions, we will be glad to help!

Best regards,
Yuriy

0 votes
In reply to: Candle width

Yuriy,

I just figured I’d report back and say that I was able to get the candle widths set the way I want by adjusting the XAxis.VisibleRange, which worked the way you said it would. I just had to mess around with different visible ranges to get a feel for how the candles would resize. Thanks again!

1 vote

HI dlee,

You can use the AxisBase.GrowBy property to achieve this. This will add a fractional padding above/below the axis (on X or Y axis). For an example, please see here:

http://http://www.scichart.com/Abt.Controls.SciChart.SL.ExampleTestPage.html#/Abt.Controls.SciChart.Example;component/Examples/IWantTo/CreateSimpleChart/LineChartExampleView.xaml

    <!-- Create the chart surface -->
    <SciChart:SciChartSurface Name="sciChart" SciChart:ThemeManager.Theme="ExpressionDark">

        <!-- Declare RenderableSeries -->
        <SciChart:SciChartSurface.RenderableSeries>
            <SciChart:FastLineRenderableSeries SeriesColor="#FF4083B7" StrokeThickness="2"/>
        </SciChart:SciChartSurface.RenderableSeries>

        <!-- Create an X Axis with Growby -->
        <SciChart:SciChartSurface.XAxis>
            <SciChart:NumericAxis>
                <SciChart:NumericAxis.GrowBy>
                    <SciChart:DoubleRange Min="0.1" Max="0.1"/>
                </SciChart:NumericAxis.GrowBy>
            </SciChart:NumericAxis>
        </SciChart:SciChartSurface.XAxis>

        <!-- Create a Y Axis with Growby -->
        <SciChart:SciChartSurface.YAxis>
            <SciChart:NumericAxis>
                <SciChart:NumericAxis.GrowBy>
                    <SciChart:DoubleRange Min="0.1" Max="0.1"/>
                </SciChart:NumericAxis.GrowBy>
            </SciChart:NumericAxis>
        </SciChart:SciChartSurface.YAxis>

    </SciChart:SciChartSurface>

which results in this output:

0 votes

Hi Manish,

Which element’s mousemove event are you subscribing to? If you subscribed to SciChartSurface.MouseMove then please note the Mouse point will be relative to the SciChartSurface control (which includes the left YAxis), not relative to the chart pane.

To get the correct output you will have to transform the mouse point using the following code:

// Transforms a mouse point from the RootGrid (which hosts the ScichartSurface) 
// relative to the ModifierSurface (which is overlaid on the chart area only)
var transformedPoint = sciChartSurface.RootGrid.TranslatePoint(inputPoint, sciChartSurface.ModifierSurface);

Now that the mouse point is relative to the ModifierSurface (which covers the chart viewport area) the hit-test will work.

You can see another example of this transformation in the following example:
http://http://www.scichart.com/Abt.Controls.SciChart.SL.ExampleTestPage.html#/Abt.Controls.SciChart.Example;component/Examples/IWantTo/InspectDatapoints/HitTestDatapoints.xaml

// Taken from example IWantTo/InspectDataPoints/HitTestDataPoints
private void SciChartSurfaceMouseLeftButtonUp(object sender, MouseButtonEventArgs e)
{
   // Perform the hit test relative to the GridLinesPanel
   Point mousePoint = e.GetPosition(sciChartSurface.GridLinesPanel as UIElement);
}

Finally, it sounds to me like you are trying to replicate the behaviour of the RolloverModifier? Have you considered using this modifier instead in your code?

If you need some custom actions then creating a ChartModifier (that inherits or replaces RolloverModifier) might be the best way to go.

Feel free to post if you need further assistance.

Best regards,
Andrew

0 votes

Hi there,

Could you try out to set SciChartSurface.AutoRangeOnStartup=”False”?
Please, let me know if this helps!

Best regards,
Yuriy

0 votes
In reply to: Data Point Template

Hi Alex,

Just to interject here. The Scatter plot, or PointMarker on line plots are not WPF elements – they are rendered as bitmaps, so control templating is not possible (as yuriy point out).

However, there is another way to achieve what you want in the upcoming v1.5 version. See this article here:
http://http://www.scichart.com/scichart-v1-5-beta-preview-q4-2012/

You will notice we have included a PaletteProvider class to override data-point colours. This works for OHLC, Candlestick and Column charts at present. We’re thinking of a way to extend it to lines, mountain charts and scatter charts.

Alternatively, another way would be to use the new annotations API. Take a look here:
http://http://www.scichart.com/annotations-are-easy/

If your offline data-points were rare it wouldn’t be difficult using this API to overlay a grayed out point or some other marker to demonstrate it to the user.

Regarding v1.5, we’re about 4 weeks off release. Many features are done, but productionising the code is going to take the remainder of the time.

Hope this is helpful!

Andrew

0 votes

Hi Joerg, the grow-by is a multiplying factor. You could try this:

Instead of

var currentRange = this.YAxis.VisibleRange.AsDoubleRange();
  
if (value > currentRange.Max)
{
    var growByRange = this.YAxis.GrowBy.AsDoubleRange();
    this.YAxis.VisibleRange.SetMinMax(0, currentRange.Max + growByRange.Max);
}

try

// Decouple the instance so you don't modify original
var currentRange = (DoubleRange)this.YAxis.VisibleRange.AsDoubleRange().Clone();
  
if (value > currentRange.Max)
{
    // Expand range
    currentRange.Max = value;
    
    // Apply growby
    currentRange = currentRange.GrowBy(this.YAxis.GrowBy);    

    this.YAxis.VisibleRange.SetMinMax(0, currentRange.Max);
}

Also, a hidden feature in v1.5 will be the ability to put this logic into a “ViewportManager” derived class. This is called by SciChart in the render loop to get the new visible range, so it will be a good place to put this code.

Hope this helps!

0 votes
In reply to: Text Category Axis

Hello there,

We are going to introduce LabelFormatter property in AxisBase class, which allows to change text on axis. To do this, you need to implement ILabelFormatter interface, which contains a method

        public string FormatLabel(IComparable dataValue)
        {
          ...
        }

So, you will be able to change axis labels text depending on data value at this point. Is this suitable for you? Will that approach work in your case?

Best regards,
Yuriy

0 votes

Hi Andrew,

I’ve tried it out and found a solution, you need just to add GrowBy to YAxis:

        &lt;SciChart:SciChartSurface.YAxis&gt;
            &lt;SciChart:NumericAxis AutoRange=&quot;True&quot;
                                  DrawLabels=&quot;False&quot;
                                  MaxAutoTicks=&quot;0&quot;&gt;

              &lt;SciChart:NumericAxis.GrowBy&gt;
                    &lt;SciChart:DoubleRange Max=&quot;0.1&quot; Min=&quot;0.1&quot; /&gt;
                &lt;/SciChart:NumericAxis.GrowBy&gt;

            &lt;/SciChart:NumericAxis&gt;
        &lt;/SciChart:SciChartSurface.YAxis&gt;

It looks a bit strange, but it works properly. Please, try out and let me know if this helps.

Anyway, this issue needs further investigation.

Thanks,
Yuriy

1 vote

Hi there,

No, we don’t have examples how to do this via MVVM, but it isn’t hard. You need to have some string property in your ViewModel, and bind ThemeManager.Theme to it. Saying, you have Theme property in VM:

        public string Theme
        {
            get { return _theme; }
            set
            {
                _theme = value;
                OnPropertyChanged("Theme");
            }
        }

than you binding expression should be:

                            <sciChart:SciChartSurface ...
sciChart:ThemeManager.Theme="{Binding Theme}">
...
                            <sciChart:SciChartSurface />

Also, if you want to get all themes into a combo box and select via MVVM you can do this:

<ComboBox ItemsSource="{Binding sciChart:ThemeManager.AllThemes}"
 SelectedItem="{Binding Theme, Mode=TwoWay}"/>

Please, try this and and don’t hesitate to ask if you have any questions!

Best regards,
Yuriy

0 votes

Hi Andy,

The concept you’re talking about is called a “Sparkline”. Multiple tiny charts without axes shown in a data-grid. Its a very useful visualization concept.

I assume you’ve seen this demo? This shows 16x charts inside an ItemsControl updating in real-time:
http://http://www.scichart.com/Abt.Controls.SciChart.SL.ExampleTestPage.html#/Abt.Controls.SciChart.Example;component/Examples/IWantTo/CreateRealtimeChart/EEGChannelsDemo/EEGExampleView.xaml

Yes, there is a performance overhead with showing more charts, but SciChart is pretty well equipped to deal with it. How many charts are you going to show? I’d recommend using something like the above (the ItemsControl demo) and hiding YAxis, XAxis. Also use FastLineRenderableSeries.ResamplingMode = ResamplingMode.Mid, as this will aggressively strip points (at expense of lower resolution).

I would recommend throttling the data you push to N charts though as this will be a bottleneck (e.g. dont dump a million points in each all in real-time if the chart is scrolled out of view!).

Render to bitmap is another technique you can try. There are a few threads on this forum showing different techniques. However, in a real-time context that won’t be any faster than just having the actual chart.

Let me know how you progress

Andrew

1 vote
In reply to: Pie Charts?

Hi Ron,

It’s not on our roadmap, but we have had a few requests for more standard presentation charts. My question to you is – why not use the WPF Toolkit chart, which provides very good Pie-chart functionality (and for free!). Pie charts don’t often need millions of points!

Best regards,
Andrew

0 votes
In reply to: Custom Theme

Hi Jane,

Sure, the themes are just Xaml control templates. We don’t publish them or show how to modify because the control template internals can change between one release and another. Customising backgrounds, axis gridlines or text labels is quite easy though.

What do you want to do?

Best regards,
Andrew

Edit:

Take a look at this example:
http://http://www.scichart.com/Abt.Controls.SciChart.SL.ExampleTestPage.html#/Abt.Controls.SciChart.Example;component/Examples/IWantTo/StyleAChart/XamlStyling.xaml

This shows how to style certain elements. If all you want to do is a background change, or change text colours it should be possible by overriding the various setters.

3 votes

Hi Marcel,

Keyboard input for ChartModifiers is a hotly requested feature. We haven’t implemented this yet, but you can achieve the same effect by a workaround.

Start by inheriting RolloverModifier and subscribing to the KeyDown event of the parent Window. E.g.

public class KeydownRolloverModifier : RolloverModifier
{
    private double positionFraction = 0.0;

    void KeydownRolloverModifier_PreviewKeyDown(object sender, KeyEventArgs e)
    {
        if (e.Key == Key.Right)
        {
            positionFraction += 0.01;
        }
        if (e.Key == Key.Left)
        {
            positionFraction -= 0.01;
        }

        // Constrain to 0.0, 1.0
        positionFraction = positionFraction > 1.0 ? 1.0 : positionFraction < 0.0 ? 0.0 : positionFraction;

        UpdateRollover(positionFraction);
    }

    public override void OnAttached()
    {
        base.OnAttached();
        var scichart = (ParentSurface as SciChartSurface);
        scichart.FindLogicalParent<Window>().PreviewKeyDown +=
            new KeyEventHandler(KeydownRolloverModifier_PreviewKeyDown);
    }

    public override void OnModifierMouseMove(ModifierMouseArgs e)
    {
        // Don't call base. This way the mouse does not change the cursor position
        // base.OnModifierMouseMove(e);
    }

    private void UpdateRollover(double fraction)
    {
        var point = new Point(ModifierSurface.Width * fraction, 0);
        point = ModifierSurface.TranslatePoint(point, RootGrid);
        base.OnModifierMouseMove(new ModifierMouseArgs(point, MouseButtons.None, MouseModifier.None, true));
    }
}

The code for FindLogicalParent is as follows:

public static class FrameworkElementExtensions
{
    public static T FindLogicalParent<T>(this FrameworkElement element) where T : FrameworkElement
    {
        var parent = (FrameworkElement)element.Parent;

        if (parent is T)
            return (T)parent;

        return parent.FindLogicalParent<T>();
    }
}

Using the above you should get a key right/left response by moving the rollover. It’ll move by a percentage each time, not to the next data-point. If you wish to achieve data-point by point moves, then maybe take a look at the HitTest API (BaseRenderableSeries.HitTest). This is used in the base RolloverModifier class to get the X,Y values of data-points.

Best regards,
Andrew

0 votes
In reply to: MVVM Printing

I am considering applying server-side licensing for my javerScript application.

In the document below, there is a phrase “Our server-side licensing component is written in C++.”
(https://support.scichart.com/index.php?/Knowledgebase/Article/View/17256/42/)

However, there is only asp.net sample code on the provided github.
(https://github.com/ABTSoftware/SciChart.JS.Examples/tree/master/Sandbox/demo-dotnet-server-licensing)

I wonder if there is a sample code implemented in C++ for server-side licensing.

Can you provide c++ sample code?
Also, are there any examples to run on Ubuntu?

1 vote

Hi Andy,

Simplest way to do this would be to subclass TextAnnotation and apply the tooltip in Xaml. To do this, create a new UserControl (xaml, code-behind), then change the base type to TextAnnotation (remember to do this both in code-behind and root element in Xaml). Then apply the tooltip. Your xaml will look something like this:

XAML

<s:TextAnnotation Text="{Binding TextOnViewModel}" X1="{Binding X1OnViewModel}" Y1="{Binding Y1OnViewModel" 
      Foreground="#333333" Background="#AAFFFFFF" BorderBrush="#777777" BorderThickness="1">
   <TooltipService.Tooltip>
        <Grid>
            <!-- Put any xaml here with bindings to data context -->
        </Grid>
   </TooltipService.Tooltip>
</s:TextAnnotation>

Code Behind

public class CustomTextAnnotation : TextAnnotation
{
     public CustomTextAnnotation()
     {
          InitializeComponent();
     }
}

I’ve gone one step further and created a custom tutorial for you! This uses the ChartModifier API to create a custom chart modifier which binds to a collection of LabelViewModels. It creates the TextAnnotations in the modifier, so you don’t have any TextAnnotation creation in your viewmodel.

To run the example you’ll need to extract the zip file and include the MainWindow and all files in a new VS2010 solution. You’ll also need to reference the RandomWalkGenerator class from the examples source and remove the [UserExample] attribute.

The result looks like this. Hover a label to see its databound tooltip!

0 votes

Hello there,

Please, take a look into attached example. It demonstrates vertical line annotations creation in ViewModel.
To get back value of line, you should bind to X1 property of anotation, or to LabelValue property of VerticalLineAnnotation (by default it is bind to X1). Also you can add more labels via VerticalLineAnnotation.AnnotationLabels property.

Also, you could look into DragHorizontalTreshold example.

Best regards,
Yuriy

0 votes

Hello Yan,

Thanks for reporting this issue. I assume you including the license file as per instructions at http://www.scichart.com/licensing-scichart ?

In the current version of SciChart (v1.3) the license file is discovered automatically during startup. In v1.5 we have included the option to bootstrap the chart by supplying a license key before the chart is shown, for instance, during application initialization (instructions also here).

New to v1.5 – Preloading of license
key In v1.5 Beta if you have a license key in a non-XML format,
you can license the product by calling the following code. This must
be called once before any SciChartSurface instances
are created.

SciChartSurface.SetLicenseKey("77f1jagAG==@Gaagg...");

I am certain this new feature will help you. Please note the license keys for v1.3 are not compatible with v1.5. Please email us with your order ID and I’ll put you on the upgrade list.

Finally if licensing startup time continues to cause problems, one option is to become a source code customer. The source code distribution has no licensing code and is not obfuscated, so the library boots a lot faster.

Best regards,
Andrew

Showing 61 - 80 of 6k results