protected virtual void UpdatePointerValue(Axis axis) { var grid = chart.GetChartComponent <GridCoord>(axis.gridIndex); if (grid == null) { return; } if (!grid.context.isPointerEnter) { axis.context.pointerValue = double.PositiveInfinity; } else { var lastPointerValue = axis.context.pointerValue; if (axis.IsCategory()) { var dataZoom = chart.GetDataZoomOfAxis(axis); var dataCount = chart.series.Count > 0 ? chart.series[0].GetDataList(dataZoom).Count : 0; var local = chart.pointerPos; if (axis is YAxis) { float splitWid = AxisHelper.GetDataWidth(axis, grid.context.height, dataCount, dataZoom); for (int j = 0; j < axis.GetDataCount(dataZoom); j++) { float pY = grid.context.y + j * splitWid; if ((axis.boundaryGap && (local.y > pY && local.y <= pY + splitWid)) || (!axis.boundaryGap && (local.y > pY - splitWid / 2 && local.y <= pY + splitWid / 2))) { axis.context.pointerValue = j; axis.context.pointerLabelPosition = axis.GetLabelObjectPosition(j); if (j != lastPointerValue) { if (chart.onAxisPointerValueChanged != null) { chart.onAxisPointerValueChanged(axis, j); } } break; } } } else { float splitWid = AxisHelper.GetDataWidth(axis, grid.context.width, dataCount, dataZoom); for (int j = 0; j < axis.GetDataCount(dataZoom); j++) { float pX = grid.context.x + j * splitWid; if ((axis.boundaryGap && (local.x > pX && local.x <= pX + splitWid)) || (!axis.boundaryGap && (local.x > pX - splitWid / 2 && local.x <= pX + splitWid / 2))) { axis.context.pointerValue = j; axis.context.pointerLabelPosition = axis.GetLabelObjectPosition(j); if (j != lastPointerValue) { if (chart.onAxisPointerValueChanged != null) { chart.onAxisPointerValueChanged(axis, j); } } break; } } } } else { if (axis is YAxis) { var yRate = axis.context.minMaxRange / grid.context.height; var yValue = yRate * (chart.pointerPos.y - grid.context.y - axis.context.offset); if (axis.context.minValue > 0) { yValue += axis.context.minValue; } var labelX = axis.GetLabelObjectPosition(0).x; axis.context.pointerValue = yValue; axis.context.pointerLabelPosition = new Vector3(labelX, chart.pointerPos.y); if (yValue != lastPointerValue) { if (chart.onAxisPointerValueChanged != null) { chart.onAxisPointerValueChanged(axis, yValue); } } } else { var xRate = axis.context.minMaxRange / grid.context.width; var xValue = xRate * (chart.pointerPos.x - grid.context.x - axis.context.offset); if (axis.context.minValue > 0) { xValue += axis.context.minValue; } var labelY = axis.GetLabelObjectPosition(0).y; axis.context.pointerValue = xValue; axis.context.pointerLabelPosition = new Vector3(chart.pointerPos.x, labelY); if (xValue != lastPointerValue) { if (chart.onAxisPointerValueChanged != null) { chart.onAxisPointerValueChanged(axis, xValue); } } } } } }