Pre loader

VerticleSliceModifier Does Not seem to work!! No Slices are appearing!!

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

Hi,
I have done everything possible, but I can’t seem to get the vertical slice modifier to appear. I have wired the function just how the ‘InspectDataPoints => Create Verticle Slices’ SciCharts Example.

Unfortunately, it just doesn’t seem to work! Nothing is popping up when I press the ‘Add Slice’ button. The only difference with the example from SciCharts is that I am using a DateTime Axis.

private void OnCreateSliceClick(object sender, RoutedEventArgs e)
        {
            MouseButtonEventHandler mouseClick = null;
            mouseClick = (s, arg) =>
            {
                this.MouseLeftButtonUp -= mouseClick;
                hintText.Visibility = Visibility.Collapsed;
                var mousePoint = arg.GetPosition((UIElement)this.sciChart.GridLinesPanel).X;

                var slice = new VerticalLineAnnotation()
                {           
                    //X1 = new DateTime(2012, 1, 7, 8, 0, 0),
                    X1 = this.sciChart.XAxis.GetDataValue(mousePoint),
                    Style = (Style)Resources["sliceStyle"]
                };

                sliceModifier.VerticalLines.Add(slice);
            };

            hintText.Visibility = Visibility.Visible;
            this.MouseLeftButtonUp += mouseClick;
        }

And then I tried changing the Date Axis using the following code

var mousePoint = arg.GetPosition((UIElement)this.sciChart.GridLinesPanel).X;
var categoryCoordCalc = sciChart.XAxis.GetCurrentCoordinateCalculator() as ICategoryCoordinateCalculator;
var dataPointIndex = (int)categoryCoordCalc.GetDataValue(mousePoint);

unfortunately, the ‘categoryCoordCalc’ value returns a null!!!

I am so stuck!! Please help me!

  • You must to post comments
0
0

If you are using CategoryDateTimeAxis, then please set X1 values on vertical slices as indices to your data.

If you are using DateTImeAxis, then set X1 values to Dates.

The Axis.GetCurrentCoordinateCalculator() and Axis.GetCoordinate() / GetDataValue() depend on the axis having been drawn to the screen (as we need to know the axis size), so these functions are only available after the SciChartSurface has first drawn.

Does this help?

  • 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