Pre loader

How to highlight even/odd days on time axis?

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

I want to paint my time axis like this:
Chessboard ruler
Or just highlight last week, day, hour.
Is there way to apply style only on part of axis?

Version
5.1.0.11243
  • You must to post comments
1
0

I’ve done something. Share it here.

public partial class RulerAnnotation : CompositeAnnotation {

    private new const float Height = 0.003f;
    private const int Count = 24 / 3;

    private static readonly TimeSpan Duration = new TimeSpan( 24, 0, 0 ); // 24 hours

    private static readonly Brush[] Brushes = new Brush[Count] {
        new SolidColorBrush( Color.FromRgb(63 * 1, 0, 0) ),
        new SolidColorBrush( Color.FromRgb(63 * 2, 0, 0) ),
        new SolidColorBrush( Color.FromRgb(63 * 3, 0, 0) ),
        new SolidColorBrush( Color.FromRgb(63 * 4, 0, 0) ),

        new SolidColorBrush( Color.FromRgb(0, 63 * 1, 0) ),
        new SolidColorBrush( Color.FromRgb(0, 63 * 2, 0) ),
        new SolidColorBrush( Color.FromRgb(0, 63 * 3, 0) ),
        new SolidColorBrush( Color.FromRgb(0, 63 * 4, 0) ),
    };

    public RulerAnnotation() {
        InitializeComponent();
        this.Loaded += OnLoaded;
    }

    private void OnLoaded(object sender, RoutedEventArgs routedEventArgs) {
        if (DesignerProperties.GetIsInDesignMode( this )) return;

        var max = (DateTime) XAxis.DataRange.Max;
        var time = max.AddHours( -max.Hour ).AddMinutes( -max.Minute ).AddSeconds( -max.Second );

        CoordinateMode = AnnotationCoordinateMode.RelativeY;
        X1 = time;
        X2 = time.Add( Duration );
        Y1 = 1 - Height;
        Y2 = 1f;

        foreach (var item in GetBoxes()) {
            Annotations.Add( item );
        }
    }

    private static IEnumerable<BoxAnnotation> GetBoxes() {
        for (int i = 0; i < Count; i++) {
            yield return new BoxAnnotation() {
                Background = Brushes[i],

                CoordinateMode = AnnotationCoordinateMode.Relative,
                X1 = (float) i / Count,
                X2 = (float) (i + 1) / Count,
                Y1 = 0,
                Y2 = 1
            };
        }
    }

}
  • You must to post comments
0
0

I am considering applying server-side licensing for my javerScript application.

In the document below, there is a phrase “Our server-side licensing component is written in C++.”
(https://support-dev.scichart.com/index.php?/Knowledgebase/Article/View/17256/42/)

However, there is only asp.net sample code on the provided github.
(https://github.com/ABTSoftware/SciChart.JS.Examples/tree/master/Sandbox/demo-dotnet-server-licensing)

I wonder if there is a sample code implemented in C++ for server-side licensing.

Can you provide c++ sample code?
Also, are there any examples to run on Ubuntu?

  • Denis Denis
    I want to paint even/odd days on time axis in yellow/black colors.
  • You must to post comments
0
0

I’m afraid what you want to do is not possible without a source-code license, or without deep customisation of axis templates.

In the axis class we have three methods for drawing.

  1. AxisBase.OnDraw(IRenderContext2D renderContext, IRenderPassData renderPassData)
  2. AxisBase.DrawGridLines(IRenderContext2D renderContext, Style gridLineStyle, IEnumerable coordsToDraw)
  3. AxisBase.DrawBands(IRenderContext2D renderContext, double[] ticks, float[] ticksCoords)

These draw the gridlines and the bands on the main render surface itself, so the RenderContext is the same one shared with the chart.

The ticks are drawn on the axis itself. In AxisPanel.DrawTicks. This is where we create a Rendercontext and draw ticks on the axis.

So the only way to do this is to either modify the source code for AxisPanel.DrawTicks, or substitute your own class for AxisPanel in the template for the axis and to modify how it draws ticks. Either way doing this without a source-code license will be very difficult.

Sorry I can’t be more help,

Best regards,
Andrew

  • Denis Denis
    Bad. I’m always misunderstanding what the period of time I watch. But I can paint it on chart surface. Just add translucent column chart. It’s better than nothing.
  • Andrew Burnett-Thompson
    Yes, good idea. It’s much easier to paint it on the chart with custom series, or annotations
  • You must to post comments
0
0

Ok, I added a few box annotations on chart surface. And I want my boxes to be between background and series. So, I used AnnotationCanvas.BelowChart.
And I see something not good https://youtu.be/PlORkhwW69A ?
Is it ok?

Also, can I use AnnotationCanvas.XAxis to paint annotations on time axis?
Now if I use AnnotationCanvas.XAxis then I can’t see my annotations.

  • Andrew Burnett-Thompson
    Hi Denis, the annotations are appearing below the Axis Bands. If you set Axis.DrawMajorBands = false they will appear correctly.
  • Denis Denis
    I still don’t lose hope. What is ModifierAxisCanvas? Can I use it to draw on time axis? Are there examples with ModifierAxisCanvas? Or as you said without sources I can’t do it?
  • You must to post comments
Showing 4 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