Pre loader

PaletteProvider xValue doesn't match index

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

1
0

Updated 1/21/15 to be clearer and provide code to reproduce.

I am trying to use a custom PaletteProvider to change the color of a data point on mouse over using a hit test, so I am comparing the xValue passed into the GetColor method to the HitTestInfo.XValue and returning the updated color if they match. This works until I have data points with no color.

To replicate this issue create a FastColumnRenderable series and add the following values:
1,1
2,0
3,2
4,0
5,3

With these values the PaletteProvider GetColor method will only be called three times with X values equal to 1, 2, and 3 the expected values are 1, 3, and 5. It seems that it is returning the XValues for the first three data points instead of the first, third, and fifth data points.

Here is the example showing the problem:

SciChartPaletteProviderBug.xaml

 <Page x:Class="SciChartPaletteProviderBug"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
    xmlns:scichart="http://schemas.abtsoftware.co.uk/scichart"
    mc:Ignorable="d" 
    d:DesignHeight="300" d:DesignWidth="300"
Title="SciChartPaletteProviderBug" Loaded="Page_Loaded_1">

<Grid>
    <scichart:SciChartSurface x:Name="sciChart">
        <scichart:SciChartSurface.RenderableSeries>
            <scichart:FastColumnRenderableSeries x:Name="columnSeries">
            </scichart:FastColumnRenderableSeries>
        </scichart:SciChartSurface.RenderableSeries>
        <scichart:SciChartSurface.XAxes>
            <scichart:NumericAxis AxisTitle="X"></scichart:NumericAxis>
        </scichart:SciChartSurface.XAxes>
        <scichart:SciChartSurface.YAxes>
            <scichart:NumericAxis AxisTitle="Y"></scichart:NumericAxis>
        </scichart:SciChartSurface.YAxes>
    </scichart:SciChartSurface>
</Grid>
</Page>

SciChartPaletteProviderBug.xaml.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Abt.Controls.SciChart.Model.DataSeries;

namespace SciChartPaletteProviderBug
{
    /// <summary>
    /// Interaction logic for SciChartPaletteProviderBug.xaml
    /// </summary>
    public partial class SciChartPaletteProviderBug : Page
    {
        public SciChartPaletteProviderBug()
        {
            InitializeComponent();
        }

        private void Page_Loaded_1(object sender, RoutedEventArgs e)
        {
            XyDataSeries<int, int> dataSeries = new XyDataSeries<int, int>();
            dataSeries.Append(1, 1);
            dataSeries.Append(2, 0);
            dataSeries.Append(3, 2);
            dataSeries.Append(4, 0);
            dataSeries.Append(5, 3);
            using (this.sciChart.SuspendUpdates())
            {
                this.columnSeries.DataSeries = dataSeries;
                this.columnSeries.PaletteProvider = new PointPaletteProvider();
            }
            this.sciChart.ZoomExtents();
        }
    }
}

PointPaletteProvider.cs

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Media;
using Abt.Controls.SciChart.Visuals.RenderableSeries;

namespace SciChartPaletteProviderBug
{
   class PointPaletteProvider : IPaletteProvider
   {
      public Color? GetColor(IRenderableSeries series, double xValue, double yValue)
      {
              MessageBox.Show(String.Format("X value = {0}, Y value = {1}", xValue.ToString() , yValue.ToString()));
              return null;
      }
}
  • You must to post comments
0
0

Hi Steve,

My apologies for not answering this sooner, its hard to catch everything on a forum. We also have priority support for Pro/Source customers, which we have a 1-day turnaround on.

Ok, the answer to your query is that the double value is equivalent to DateTime.Ticks, so it is the x data value, not an index, but you need to transform it back to a DateTime using this code

 new DateTime((long)xValue)

The only exception is if you are using CategoryDateTimeAxis, then yes, the XValue is the index.

Are you using CategoryDateTimeAxis or DateTimeAxis? I would appreciate it if you could modify your question with a small code sample to reproduce the issue. You’ve given us some steps but its still unclear exactly how to repro.

Best regards,
Andrew

  • Steve Toohey
    Updated the question with sample source code to reproduce the issue.
  • Steve Toohey
    Hi Andrew, with the updated code example are you able to reproduce the issue now?
  • 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