viewxy - annotation x axis values changed between v7 and v8

A forum dedicated to WinForms version of LightningChart Ultimate.

Moderator: Arction_LasseP

greggorob64
Posts: 183
Joined: Tue Mar 18, 2014 2:55 pm

viewxy - annotation x axis values changed between v7 and v8

Post by greggorob64 » Tue Jun 20, 2017 6:12 pm

In my app, I have a mode that stacks all of the axis as segments, as show in the first screenshot below. I am attempting to draw annotations as "Splitters" between each segment, to visually seperate each segment. After I upgraded from v7 to v8, the location is not getting set correctly. I'm using "Value binding" for the annotation.

In screenshot 2 you can note that im settings 0 to ~8 as my location, but its drawing at 4-[something more]. I'm not sure what changed. It strikes me that there could be some change to the anchoring? I dunno. After screenshot 2 is the code I use to setup the annotation. Screenshot 3 is what it was supposed to look like.

To emphasize, this worked correctly this morning. I upgraded to v8 and it started doing this. Alternatively, is there a better way to do this? Its super annoying and tedious to draw all of these annotations between each segment. If there was some way to automatically put in some kind of seperator, that'd be sweet.

Thanks for the help!






// Image showing the stacked axis. The rectangles in the middle i call "segment boundaries". The used to line up with the length of the X axis, but don't anymore.
Image

// Code producing the values to be set for the axis
Image

Code: Select all

  AnnotationXY GenerateAnnotation()
      {
         var line = new AnnotationXYWithName(
            this.Chart.ViewXY,
            this.Chart.ViewXY.XAxes[0],
            this.YAxis,
            "SegmentBoundary/GenerateAnnotation");

         line.ResizeByMouse = false;
         line.RotateByMouse = false;
         //line.LocationCoordinateSystem = CoordinateSystem.ScreenCoordinates;
         line.TargetCoordinateSystem = AnnotationTargetCoordinates.AxisValues;
         line.LocationCoordinateSystem = CoordinateSystem.AxisValues;
         line.Sizing = AnnotationXYSizing.AxisValuesBoundaries;
         line.ClipInsideGraph = false;
         line.Anchor = new PointFloatXY(0, 0);
         line.Shadow.Visible = false;
         line.KeepVisible = true;
         line.MouseInteraction = false;
         line.BorderLineStyle.Width = 1;

         line.Fill.GradientFill = GradientFill.Solid;
         line.Fill.Style = RectFillStyle.ColorOnly;

         var color = this.SegmentCollection.getChartBackColor();
         line.Fill.Color = Color.FromArgb(color.R, color.G, color.B);
         line.BorderLineStyle.Color = Color.FromArgb(105, 105, 105);

         // won't show until the location has been set
         line.Visible = false;
         line.Style = AnnotationStyle.Rectangle;
         line.AnchorAdjustByMouse = false;
         line.Text = string.Empty;

         return line;
      }
Image

greggorob64
Posts: 183
Joined: Tue Mar 18, 2014 2:55 pm

Re: viewxy - annotation x axis values changed between v7 and

Post by greggorob64 » Tue Jun 20, 2017 6:36 pm

I dug into the source (Sorry if im doing something bad by reposting this on here), but in AnnotationXY.cs:1191 is a call to

Code: Select all

fMax = (float)m_axisX.ValueToCoordNonDPId(
, which returns the CORRECT xstart and xend. At around line 1238 there's a another method call to build the rectangle

Code: Select all

pnRenderLocationCoord = new PointFloat((fMin + fMax) / 2, (fTop + fBottom) / 2f);
. This is not the rectangle I wanted it, its averaging the X axis value as the start point, which is confusing to me.

ArctionKestutis
Posts: 386
Joined: Mon Mar 14, 2016 9:22 am

Re: viewxy - annotation x axis values changed between v7 and

Post by ArctionKestutis » Wed Jun 21, 2017 9:07 am

Just quick question. Why you are not using ConstantLine as splitter. This is much simple object and automatically rendered between X min-max. The usage could be found in our Demo App example "Segments with splitters".

All the best.

ArctionKestutis
Posts: 386
Joined: Mon Mar 14, 2016 9:22 am

Re: viewxy - annotation x axis values changed between v7 and

Post by ArctionKestutis » Wed Jun 21, 2017 12:37 pm

Back to your question about Annotation.

The pnRenderLocationCoord is the estimated center of the Annotation box. Therefore, calculations are correct.
If you would keep default Annotation.Anchor values {0.5 0.5}, when everything will be fine. The Annotation-splitter is shifted because you set Anchor to zero

Code: Select all

line.Anchor = new PointFloatXY(0, 0);
AnnotationAnchor.jpg
AnnotationAnchor.jpg (55.06 KiB) Viewed 10176 times
All the best.

greggorob64
Posts: 183
Joined: Tue Mar 18, 2014 2:55 pm

Re: viewxy - annotation x axis values changed between v7 and

Post by greggorob64 » Wed Jun 21, 2017 7:34 pm

ArctionKestutis wrote:Just quick question. Why you are not using ConstantLine as splitter. This is much simple object and automatically rendered between X min-max. The usage could be found in our Demo App example "Segments with splitters".

All the best.
I have no clue why I'm not using a constant line, I don't remember :) . I think that I want the appearance of having a different color line and border, so I changed it from a constant line to an annotation. I followed the example pasi recommended here, and converted it over to an annotation.

viewtopic.php?f=15&t=985&p=3557#p3557

greggorob64
Posts: 183
Joined: Tue Mar 18, 2014 2:55 pm

Re: viewxy - annotation x axis values changed between v7 and

Post by greggorob64 » Wed Jun 21, 2017 7:40 pm

Your suggestion worked, thanks! You can see I chose the gray w\ black border to make it look like different charts (for better or worse). There is a 1px overrun on the right side that didn't use to be there, which is a bummer.

Thank you

Image

ArctionKestutis
Posts: 386
Joined: Mon Mar 14, 2016 9:22 am

Re: viewxy - annotation x axis values changed between v7 and

Post by ArctionKestutis » Thu Jun 22, 2017 7:58 am

Hi Greg,

For your app, you should allow clipping inside graph:

Code: Select all

line.ClipInsideGraph = true;
This should give similar looking image as before.
I see difference came somewhere between v7.2.6.1 and v8. It is a bit philosophical question whatever one border's pixel should be outside or inside box. We will still try to find reason behind this change.

All the best.

User avatar
ArctionPasi
Posts: 1366
Joined: Tue Mar 26, 2013 10:57 pm
Location: Finland

Re: viewxy - annotation x axis values changed between v7 and

Post by ArctionPasi » Tue Jun 27, 2017 1:58 pm

1 px border overrun on the right side in annotations is probably because the have Shadow. Disable it... should help with that.
LightningChart Support Team, PT