Pre loader

DateTime axis and TickProvider

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

I tried to create a TickProvider for DateTimeaxis followed by https://www.scichart.com/documentation/win/current/webframe.html#Axis%20Ticks%20-%20TickProvider%20and%20DeltaCalculator%20API.html .

My custom provider (CustomDateTimeTickProvider) exactly same that found in url above.

<s:SciChartSurface x:Name="sciChartrtr" 
      s:ThemeManager.Theme="Chrome"
      RenderableSeries="{s:SeriesBinding ChartSeries, UpdateSourceTrigger=PropertyChanged}">
         <s:SciChartSurface.Resources>
             <vm:CustomTickProvider  x:Key="CustomTickProvider"/>
         </s:SciChartSurface.Resources>

         <s:SciChartSurface.XAxis>
               <s:DateTimeAxis DrawMajorBands="True" TickProvider="{StaticResource CustomTickProvider}" AutoTicks="True"  TextFormatting="yyyy.MM.dd" AxisTitle="Idő"/>
          </s:SciChartSurface.XAxis>
          <s:SciChartSurface.YAxis>
                <s:NumericAxis AutoRange="Always" DrawMajorBands="True" AxisAlignment="Left" GrowBy="0.02, 0.02" AxisTitle="{Binding SecondYAxisTitle}"/>
           </s:SciChartSurface.YAxis>
           <!-- YAxis, RenderableSeries omitted for brevity -->
 </s:SciChartSurface>

But my xaxis is empty. What do I wrong?
Thank you very much

Version
6
  • You must to post comments
0
0

Ok, the example works , I made some mistakes, sorry-

I created the custom tick provider, added to axis, but some label are displayed only, not all. How can I control displaying of label of ticks?
Thank you

Images
  • You must to post comments
0
0

Thanks for your answer.
No, I use DateTimeAxis in XAML:

<s:SciChartSurface.XAxis>
     <s:DateTimeAxis DrawMajorBands="True" TickProvider="{StaticResource CustomTickProvider}" AutoTicks="True"  TextFormatting="yyyy.MM.dd" AxisTitle="Idő"/>
  </s:SciChartSurface.XAxis>

My CustomTickProvider is this: (I renamed CustomDateTimeTickProvider found in example to simple CustomTickProvider)

public class CustomTickProvider : DateTimeTickProvider
{
    public override IList<IComparable> GetMajorTicks(IAxisParams axis)
    {
        // TODO: calculate ticks
        return new IComparable[]
        {
                new DateTime(2015, 01, 01),
                new DateTime(2015, 01, 02),
                new DateTime(2015, 01, 03),
            // ...
        };
    }

    public override IList<IComparable> GetMinorTicks(IAxisParams axis)
    {
        // TODO: calculate ticks
        return new IComparable[]
        {
                new DateTime(2015, 01, 01),
                new DateTime(2015, 01, 02),
                new DateTime(2015, 01, 03),
            // ...
        };
    }
}

When I debug code, the program run into GetMajorTicks function, so the function returns with the correct IList which contains the given dates, but there aren’t any displayed ticks on xaxis.

  • You must to post comments
0
0

Hi Hakan,

The DateTimeAxis requires a TickProvider which inherits DateTimeTickProvider. The one you’ve used is for a NumericAxis

In the same Documentation Link please scroll down and you should see this code. Can you try it?

Creating a custom TickProvider for a TimeSpanAxis or DateTimeAxis
The process for creating a TickProvider for a TimeSpanAxis or DateTimeAxis is similar, except you need to change the base class and return TimeSpan, or DateTime arrays.

// 1. Create a class which inherits DateTimeTickProvider
  // 2. Return an array of IComparable, but actual elements must be DateTimes
  // 3. Assign to the DateTimeAxis.TickProvider property
  public class CustomDateTimeTickProvider : DateTimeTickProvider
  {
         public override IComparable[] GetMajorTicks(IAxisParams axis)
         {
               // TODO: calculate ticks
               return new IComparable[]
               {
                      new DateTime(2015, 01, 01),
                      new DateTime(2015, 01, 02),
                      new DateTime(2015, 01, 03),
                      // ...
               };
         }
         public override IComparable[] GetMinorTicks(IAxisParams axis)
         {
               // TODO: calculate ticks
               return new IComparable[]
               {
                      new DateTime(2015, 01, 01),
                      new DateTime(2015, 01, 02),
                      new DateTime(2015, 01, 03),
                      // ...
               };
         }
  }
  

Best regards,
Andrew

  • You must to post comments
Showing 3 results
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