mirror of
https://github.com/XCharts-Team/XCharts.git
synced 2026-05-30 13:28:47 +00:00
[optimize][visualmap] support horizontal gradient
This commit is contained in:
@@ -76,7 +76,9 @@ namespace XCharts.Runtime
|
|||||||
if (axis.IsCategory() && axis.boundaryGap)
|
if (axis.IsCategory() && axis.boundaryGap)
|
||||||
{
|
{
|
||||||
float startX = grid.context.x + axis.context.scaleWidth / 2;
|
float startX = grid.context.x + axis.context.scaleWidth / 2;
|
||||||
value = (int)(min + (pos.x - startX) / (grid.context.width - axis.context.scaleWidth) * (max - min));
|
value = (min + (pos.x - startX) / (grid.context.width - axis.context.scaleWidth) * (max - min));
|
||||||
|
if (visualMap.IsPiecewise())
|
||||||
|
value = (int)value;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -87,17 +89,19 @@ namespace XCharts.Runtime
|
|||||||
{
|
{
|
||||||
min = relativedAxis.context.minValue;
|
min = relativedAxis.context.minValue;
|
||||||
max = relativedAxis.context.maxValue;
|
max = relativedAxis.context.maxValue;
|
||||||
|
|
||||||
if (relativedAxis.IsCategory() && relativedAxis.boundaryGap)
|
if (relativedAxis.IsCategory() && relativedAxis.boundaryGap)
|
||||||
{
|
{
|
||||||
float startY = grid.context.y + relativedAxis.context.scaleWidth / 2;
|
float startY = grid.context.y + relativedAxis.context.scaleWidth / 2;
|
||||||
value = (int)(min + (pos.y - startY) / (grid.context.height - relativedAxis.context.scaleWidth) * (max - min));
|
value = (min + (pos.y - startY) / (grid.context.height - relativedAxis.context.scaleWidth) * (max - min));
|
||||||
|
if (visualMap.IsPiecewise())
|
||||||
|
value = (int)value;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
value = min + (pos.y - grid.context.y) / grid.context.height * (max - min);
|
value = min + (pos.y - grid.context.y) / grid.context.height * (max - min);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var color = visualMap.GetColor(value);
|
var color = visualMap.GetColor(value);
|
||||||
if (ChartHelper.IsClearColor(color))
|
if (ChartHelper.IsClearColor(color))
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -97,15 +97,13 @@ namespace XCharts.Runtime
|
|||||||
if (UGLHelper.GetIntersection(lp, tp, axisStartPos, axisEndPos, ref ip))
|
if (UGLHelper.GetIntersection(lp, tp, axisStartPos, axisEndPos, ref ip))
|
||||||
tp = ip;
|
tp = ip;
|
||||||
}
|
}
|
||||||
|
var zp = isY ? new Vector3(zero, tp.y) : new Vector3(tp.x, zero);
|
||||||
if (isVisualMapGradient)
|
if (isVisualMapGradient)
|
||||||
{
|
{
|
||||||
color = VisualMapHelper.GetLineGradientColor(visualMap, tp, grid, axis, relativedAxis, areaColor);
|
color = VisualMapHelper.GetLineGradientColor(visualMap, zp, grid, axis, relativedAxis, areaColor);
|
||||||
toColor = color;
|
toColor = VisualMapHelper.GetLineGradientColor(visualMap, tp, grid, axis, relativedAxis, areaToColor);
|
||||||
lerp = false;
|
lerp = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
var zp = isY ? new Vector3(zero, tp.y) : new Vector3(tp.x, zero);
|
|
||||||
|
|
||||||
if (i > 0)
|
if (i > 0)
|
||||||
{
|
{
|
||||||
if ((lp.y - zero > 0 && tp.y - zero < 0) || (lp.y - zero < 0 && tp.y - zero > 0))
|
if ((lp.y - zero > 0 && tp.y - zero < 0) || (lp.y - zero < 0 && tp.y - zero > 0))
|
||||||
|
|||||||
Reference in New Issue
Block a user