mirror of
https://github.com/XCharts-Team/XCharts.git
synced 2026-05-17 05:50:09 +00:00
优化Scatter类型的Serie支持Log轴#68
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
|
||||
# 更新日志
|
||||
|
||||
* (2020.07.08) 优化`Scatter`类型的`Serie`支持`Log`轴#68
|
||||
* (2020.07.07) 修复`SerieLabel`位置错乱的问题
|
||||
* (2020.07.07) 增加`Tooltip`的`offset`参数配置偏移
|
||||
* (2020.07.06) 增加`LiquidChart`水位图
|
||||
|
||||
@@ -40,8 +40,8 @@ namespace XCharts
|
||||
if (serieData.IsDataChanged()) dataChanging = true;
|
||||
float pX = m_CoordinateX + xAxis.axisLine.width;
|
||||
float pY = m_CoordinateY + yAxis.axisLine.width;
|
||||
float xDataHig = (xValue - xAxis.runtimeMinValue) / (xAxis.runtimeMaxValue - xAxis.runtimeMinValue) * m_CoordinateWidth;
|
||||
float yDataHig = (yValue - yAxis.runtimeMinValue) / (yAxis.runtimeMaxValue - yAxis.runtimeMinValue) * m_CoordinateHeight;
|
||||
float xDataHig = GetDataHig(xAxis, xValue, m_CoordinateWidth);
|
||||
float yDataHig = GetDataHig(yAxis, yValue, m_CoordinateHeight);
|
||||
var pos = new Vector3(pX + xDataHig, pY + yDataHig);
|
||||
serie.dataPoints.Add(pos);
|
||||
serieData.runtimePosition = pos;
|
||||
@@ -83,5 +83,19 @@ namespace XCharts
|
||||
RefreshChart();
|
||||
}
|
||||
}
|
||||
|
||||
private float GetDataHig(Axis axis, float value, float totalWidth)
|
||||
{
|
||||
if (axis.IsLog())
|
||||
{
|
||||
int minIndex = axis.runtimeMinLogIndex;
|
||||
float nowIndex = axis.GetLogValue(value);
|
||||
return (nowIndex - minIndex) / (axis.splitNumber - 1) * totalWidth;
|
||||
}
|
||||
else
|
||||
{
|
||||
return (value - axis.runtimeMinValue) / (axis.runtimeMaxValue - axis.runtimeMinValue) * totalWidth;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user