Hello,So I have created a PointLineSeries in LightningChart, and I would like to add annotations to the line when I hover the mouse over it. I have written code to show the annotion box and it moves when I move the cursor, but it is blank. How can I add the value to this box? Any help would be appreciated.
- private void UpdateCursorResult()
- {
- _updatedCursorResults = true;
- _chart.BeginUpdate();
- LineSeriesCursor cursor = _chart.ViewXY.LineSeriesCursors[0];
- AnnotationXY annot = _chart.ViewXY.Annotations[0];
- float targetYCoordinate = DpiHelper.DipToPx((float)_chartViewXY.GetMarginsRect().Bottom);
- double y;
- _chart.ViewXY.YAxes[0].CoordToValue(targetYCoordinate, out y, false);
- annot.TargetAxisValues.X = cursor.ValueAtXAxis;
- annot.TargetAxisValues.Y = y;
- double seriesYValue = 0.0;
- StringBuilder sb = new StringBuilder();
- int seriesNumber = 1;
- char c = 'A';
- string channelStringFormat = "Product {0}: {2,5}";
- string value = "";
- AxisY yAxis = null;
- foreach (PointLineSeries series in _chart.ViewXY.PointLineSeries)
- {
- value = "";
- seriesYValue = GetTotalSum((int)cursor.ValueAtXAxis, (Product)(seriesNumber - 1));
- yAxis = _chart.ViewXY.YAxes[series.AssignYAxisIndex];
- value = string.Format(channelStringFormat, c, ConvertToCurrencyString(seriesYValue));
- sb.AppendLine(value);
- seriesNumber++;
- c++;
- }
- channelStringFormat = "Total sales: {0,8}";
- value = string.Format(channelStringFormat, ConvertToCurrencyString(GetTotalSum((int)cursor.ValueAtXAxis)));
- sb.AppendLine("");
- sb.AppendLine(value);
- annot.Visible = true;
- _chart.EndUpdate();
- }