Pre loader

SciChartSurface.XAxis visiblerange vs. x axis points shown

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
0

Hello all,

I have a simple scichart. It binds to a dataseries of int and double. I would like to know if the ScichartSurface.XAxis can be bound (visible range) to the datapoints on my dataseries while the x axis shows 0 to dataseries.diff. My goal is to let the user see the set of data but not have to question why the dataset begins at 400 and ends at 600. I would rather it show the data in that range but the user sees it as data from 0 to 200.

Thank you!

Edit:

I have attempted the hack:

 public partial class TestClass: UserControl
{
    public TestClass()
    {
        InitializeComponent();
        Loaded += TestClass_Loaded;
    }

    public RelativeLabelProvider _labelProvider;



    private void TestClass_Loaded(object sender, RoutedEventArgs e)
    {
        _labelProvider = new RelativeLabelProvider();
        SciChart.XAxis.LabelProvider = _labelProvider;
        SciChart.InvalidateElement();
    }

    private void TimerOnTick(object sender, EventArgs eventArgs)
    {
        // Update currentTime in LabelProvider to calculate relative labels
        _labelProvider.CurrentValue = 200;

        // Update visible range if we are in the mode to show the latest window of N seconds

        // I am lost on this line: All of my data is in a view model. Also, I don't understand how to fill in the values.
        // It seems like I need to pass my range of data and the duration of time that I want to view the data but that doesn't make             
       // sense to me. I just want to say, look at all values between points 400 and 600 but label them as 0 to 100. What should I put    
       //here? 
        SciChart.XAxis.AnimateVisibleRangeTo(new DoubleRange(300 - 100, _labelProvider.CurrentValue), TimeSpan.FromMilliseconds(280));

    }

Here is my LabelProvider:

public class RelativeLabelProvider : NumericLabelProvider
{
    // Update me with current latest time every time you append data!
    public double CurrentValue { get; set; }

    public override string FormatCursorLabel(IComparable dataValue)
    {
        // dataValue is the actual axis label value, e.g. comes from DataSeries.XValues
        double value = (double)dataValue;
        Double relative = (CurrentValue - value);

        return relative.ToString();
    }

    public override string FormatLabel(IComparable dataValue)
    {
        // dataValue is the actual axis label value, e.g. comes from DataSeries.XValues
        double value = (double)dataValue;
        Double relative = (CurrentValue - value);

        return relative.ToString();
    }
}
  • You must to post comments
0
0

Hi Ryan,

I think you can do this by workaround.

What you can do is use a NumericAxis as normal. The NumericAxis will lock to the data-range e.g. 400 to 600 and you can zoom, pan etc…

However you want to display the index to the data. To do this, you need to use the LabelProvider API. This API allows you to have full control over axis labels. All you need to do is to offset your axis labels by a certain amount, or to convert between real data-value and index.

We actually have an example of a LabelProvider to create a relative time axis here: How to Create a Scrolling Strip Chart in SciChart? (note this is using v3.x API whereas above article is v4.x).

Best regards,
Andrew

  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.

Try SciChart Today

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

Start TrialCase Studies