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
- Hakan Sukur asked 4 years ago
- You must login to post comments
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
- Andrew Burnett-Thompson answered 4 years ago
- You must login to post comments
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.
- Hakan Sukur answered 4 years ago
- You must login to post comments
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
- Hakan Sukur answered 4 years ago
- You must login to post comments
Please login first to submit.