private void RefreshDataZoomLabel() { var startIndex = (int)((xAxis.data.Count - 1) * m_DataZoom.start / 100); var endIndex = (int)((xAxis.data.Count - 1) * m_DataZoom.end / 100); if (m_DataZoomLastStartIndex != startIndex || m_DataZoomLastEndIndex != endIndex) { m_DataZoomLastStartIndex = startIndex; m_DataZoomLastEndIndex = endIndex; if (xAxis.data.Count > 0) { m_DataZoom.SetStartLabelText(xAxis.data[startIndex]); m_DataZoom.SetEndLabelText(xAxis.data[endIndex]); } InitAxisX(); } var start = coordinateX + coordinateWid * m_DataZoom.start / 100; var end = coordinateX + coordinateWid * m_DataZoom.end / 100; m_DataZoom.startLabel.transform.localPosition = new Vector3(start - 10, m_DataZoom.bottom + m_DataZoom.height / 2); m_DataZoom.endLabel.transform.localPosition = new Vector3(end + 10, m_DataZoom.bottom + m_DataZoom.height / 2); }
private void CheckDataZoomLabel(DataZoom dataZoom) { if (dataZoom.enable && dataZoom.supportSlider && dataZoom.showDetail) { Vector2 local; if (!chart.ScreenPointToChartPoint(Input.mousePosition, out local)) { dataZoom.SetLabelActive(false); return; } if (dataZoom.IsInSelectedZoom(local) || dataZoom.IsInStartZoom(local) || dataZoom.IsInEndZoom(local)) { dataZoom.SetLabelActive(true); RefreshDataZoomLabel(); } else { dataZoom.SetLabelActive(false); } } if (m_CheckDataZoomLabel) { m_CheckDataZoomLabel = false; var xAxis = chart.GetXAxis(dataZoom.xAxisIndexs[0]); var startIndex = (int)((xAxis.data.Count - 1) * dataZoom.start / 100); var endIndex = (int)((xAxis.data.Count - 1) * dataZoom.end / 100); if (m_DataZoomLastStartIndex != startIndex || m_DataZoomLastEndIndex != endIndex) { m_DataZoomLastStartIndex = startIndex; m_DataZoomLastEndIndex = endIndex; if (xAxis.data.Count > 0) { dataZoom.SetStartLabelText(xAxis.data[startIndex]); dataZoom.SetEndLabelText(xAxis.data[endIndex]); } chart.InitAxisX(); } var start = dataZoom.runtimeX + dataZoom.runtimeWidth * dataZoom.start / 100; var end = dataZoom.runtimeX + dataZoom.runtimeWidth * dataZoom.end / 100; var hig = dataZoom.runtimeHeight; dataZoom.UpdateStartLabelPosition(new Vector3(start - 10, chart.chartY + dataZoom.bottom + hig / 2)); dataZoom.UpdateEndLabelPosition(new Vector3(end + 10, chart.chartY + dataZoom.bottom + hig / 2)); } }