Page 1 of 1

AnnotationXY is appearing behind x-Axis

Posted: Tue Feb 21, 2017 12:46 pm
by abdul.qadirdeveloper
I have added AnnotationXY to the chart but it is appearing behind X-Axis, instead it was expectected to appear above everything(axes,series). following attached image shows the issue
SnapeShot of the issue, showing Annotation behind X-Axis
SnapeShot of the issue, showing Annotation behind X-Axis
AnnotationXYIssue.PNG (159.1 KiB) Viewed 18099 times
Here is the code that add annotation to the chart,

Code: Select all

            var cursorValueDisplay = new AnnotationXY(moduleModel.mainChart.ViewXY, moduleModel.mainChart.ViewXY.XAxes[0], moduleModel.mainChart.ViewXY.YAxes[0]);
            cursorValueDisplay.Style = AnnotationStyle.Rectangle;
            cursorValueDisplay.LocationCoordinateSystem = CoordinateSystem.RelativeCoordinatesToTarget;
            cursorValueDisplay.LocationRelativeOffset.X = 15;
            cursorValueDisplay.LocationRelativeOffset.Y = 0;
            cursorValueDisplay.TargetAxisValues.X = 0;//*AQChartUpdate  Target.X = 0;
            cursorValueDisplay.TargetAxisValues.Y = 0;// *AQChartUpdate Target.Y = 0;
            cursorValueDisplay.Anchor.X = 0;
            //cursorValueDisplay.Anchor.Y = 0;
            cursorValueDisplay.TextStyle.Font = new WpfFont(System.Drawing.FontFamily.GenericMonospace, 10.0F, System.Drawing.FontStyle.Regular);
            cursorValueDisplay.TextStyle.Color = Colors.Black;
            cursorValueDisplay.Text = "begintext";
            cursorValueDisplay.Fill.Color = Colors.White;
            cursorValueDisplay.Fill.GradientColor = Colors.Cyan.FromArgb(120);
            cursorValueDisplay.Visible = false;
            cursorValueDisplay.Behind = false;
            cursorValueDisplay.TargetMoveByMouse = false;
            cursorValueDisplay.RotateByMouse = false;
            cursorValueDisplay.MouseInteraction = false;
            cursorValueDisplay.ClipInsideGraph = false; //*AQChart Update LimitInsideGraphMargins = false;
            cursorValueDisplay.Sizing = AnnotationXYSizing.ScreenCoordinates;
            var size = moduleModel.mainChart.MeasureText(cursorValueDisplay.Text, cursorValueDisplay.TextStyle.Font);
            cursorValueDisplay.SizeScreenCoords.Width = size.X + 20;
            cursorValueDisplay.SizeScreenCoords.Height = size.Y + 20;
            moduleModel.mainChart.ViewXY.Annotations.Add(cursorValueDisplay);
            moduleModel.mainChart.ViewXY.LineSeriesCursors[0].ValueAtXAxis = (moduleModel.mainChart.ViewXY.XAxes[0].Maximum - moduleModel.mainChart.ViewXY.XAxes[0].Minimum) / 2;
            UpdateCursorResult();
            moduleModel.mainChart.ViewXY.LineSeriesCursors[0].ValueAtXAxis = (moduleModel.mainChart.ViewXY.XAxes[0].Maximum - moduleModel.mainChart.ViewXY.XAxes[0].Minimum) / 2;
            moduleModel.mainChart.ViewXY.LineSeriesCursors[0].Visible = true;
private void UpdateCursorResult(){
            moduleModel.mainChart.BeginUpdate();
            var lineSeriesCursor = moduleModel.mainChart.ViewXY.LineSeriesCursors[0];
            if (moduleModel.mainChart.ViewXY.Annotations.Count == 0) return;
            var cursorValueDisplay = moduleModel.mainChart.ViewXY.Annotations[0];
            UpdateValueAtLegendBox();
            // Update date and time string of X-axis value annotation
            var cursorDate = moduleModel.mainChart.ViewXY.XAxes[0].AxisValueToDateTime(lineSeriesCursor.ValueAtXAxis);
            var diffDate = DateTime.Now.Subtract(cursorDate);
            var labels = new string[] { "Time: ", "Date: ", "Offset: " };
            var padLength = labels.Max(l => l.Length);
            StringBuilder sbCursorText = new StringBuilder();
            sbCursorText.AppendLine(string.Format("{0}{1}", labels[0].PadRight(padLength), moduleModel.mainChart.ViewXY.XAxes[0].TimeString(lineSeriesCursor.ValueAtXAxis, "HH:mm:ss")));
            sbCursorText.AppendLine(string.Format("{0}{1}", labels[1].PadRight(padLength), moduleModel.mainChart.ViewXY.XAxes[0].TimeString(lineSeriesCursor.ValueAtXAxis, "ddd dd/MM/yyyy")));
            sbCursorText.AppendLine(string.Format("{0}{1} day(s) {2:00}:{3:00}:{4:00}", labels[2].PadRight(padLength), diffDate.Days, diffDate.Hours, diffDate.Minutes, diffDate.Seconds));
            cursorValueDisplay.Text = sbCursorText.ToString();
            //Set annotation target. The location is relative to target. 
            //Use graph bottom as target Y value. 
            var size = moduleModel.mainChart.MeasureText(cursorValueDisplay.Text, cursorValueDisplay.TextStyle.Font);
            cursorValueDisplay.SizeScreenCoords.Width = size.X + 70;
            cursorValueDisplay.SizeScreenCoords.Height = size.Y + 20;

            var fTargetYCoord = (float)(moduleModel.mainChart.RenderSize.Height - cursorValueDisplay.SizeScreenCoords.Height / 2);
            double dY = 0;
            moduleModel.mainChart.ViewXY.YAxes[0].CoordToValue(fTargetYCoord, out dY);
            PositionAnnotationLabelXAxis(lineSeriesCursor, cursorValueDisplay);


            cursorValueDisplay.LocationRelativeOffset.Y = 0;
            cursorValueDisplay.TargetAxisValues.X = lineSeriesCursor.ValueAtXAxis;
            cursorValueDisplay.TargetAxisValues.Y = dY;
            cursorValueDisplay.Visible = true;
            cursorValueDisplay.ChangeOrder(OrderChangeAction.BringToFront);



            moduleModel.mainChart.EndUpdate();
}

Re: AnnotationXY is appearing behind x-Axis

Posted: Tue Feb 21, 2017 2:17 pm
by ArctionPasi
Hi,

annotations don't unfortunately support rendering over axes. Please try if you can achieve preferred functionality with X axis Title or X axis Units. They support fill and border as well.

Re: AnnotationXY is appearing behind x-Axis

Posted: Tue Feb 21, 2017 2:27 pm
by abdul.qadirdeveloper
till yesterday, i was using LightningChartUltimate version 5.x, and it was already rendering Anotation over X-Axis.
I upgraded the subscription, on your recommendation, and updated to newer version, to not support, what it was supporting..
Does this make sense to tell my client that, it is not working the way it was, because we upgraded to the newer version?
will this justify, his investment?

Re: AnnotationXY is appearing behind x-Axis

Posted: Tue Feb 21, 2017 2:34 pm
by abdul.qadirdeveloper
This is how it was working in LighteningChart version 5.x
Annotation in version 5
Annotation in version 5
AnnotationXYIssue2.PNG (65.13 KiB) Viewed 18096 times

Re: AnnotationXY is appearing behind x-Axis

Posted: Tue Feb 21, 2017 2:50 pm
by ArctionPasi
Point taken. We'll discuss adding functionality to render the annotations before or after the the axes.

Re: AnnotationXY is appearing behind x-Axis

Posted: Fri Feb 24, 2017 10:23 am
by ArctionPasi
We have added a property now to control the order of Annotations vs. Axis. It's coming in v.8 soon. :P