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();
}
}
- Ryan Woods asked 8 years ago
- last edited 8 years ago
- You must login to post comments
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
- Andrew Burnett-Thompson answered 8 years ago
-
@Andrew I don’t know if it updates you, but I edited my original post. I am missing some understanding but I think I am very close. Thanks!
-
Hi Ryan, it doesnt. Only if you comment on an answer or create a new answer. So you’re stuck at appending data? Or at setting VisibleRange? To set a VisibleRange simply call AxisBase.VisibleRange = … https://www.scichart.com/documentation/v4.x/webframe.html#Axis%20Ranging%20-%20AutoRange%20and%20VisibleRange.html To set Data, you need to look here at a simple example https://www.scichart.com/documentation/v4.x/webframe.html#The%20Line%20Series%20Type.html
-
I think that I am just confused about the TimerOnTick event code. I did not understand the example that was offered in the link you provided.
-
The confusing part is this line: SciChart.XAxis.AnimateVisibleRangeTo(new DoubleRange(100, 100), TimeSpan.FromMilliseconds(100)); No matter what information I put into this line (replace the 100’s with anything else), it spans and changes by 50 in the negative direction from 0 to -450 (going from left to right).
-
You cannot set a VisibleRange with Min==Max. SciChart will automatically revert to previous known valid range, or try to compute a new one that is valid.
- You must login to post comments
Please login first to submit.