[optimize][bar] bar support clip and min-max (#196)

This commit is contained in:
monitor1394
2022-05-01 10:30:58 +08:00
parent 96b0ec45d2
commit 4e4d0bc85d
8 changed files with 19 additions and 8 deletions

View File

@@ -26,7 +26,7 @@ namespace XCharts.Editor
PropertyField("m_BarZebraWidth"); PropertyField("m_BarZebraWidth");
PropertyField("m_BarZebraGap"); PropertyField("m_BarZebraGap");
} }
PropertyField("m_Clip");
PropertyFiledMore(() => PropertyFiledMore(() =>
{ {
PropertyFieldLimitMin("m_MinShow", 0); PropertyFieldLimitMin("m_MinShow", 0);
@@ -38,7 +38,6 @@ namespace XCharts.Editor
PropertyField("m_ShowAsPositiveNumber"); PropertyField("m_ShowAsPositiveNumber");
PropertyField("m_Large"); PropertyField("m_Large");
PropertyField("m_LargeThreshold"); PropertyField("m_LargeThreshold");
PropertyField("m_Clip");
PropertyField("m_PlaceHolder"); PropertyField("m_PlaceHolder");
}); });
PropertyField("m_ItemStyle"); PropertyField("m_ItemStyle");

View File

@@ -18,6 +18,7 @@ namespace XCharts.Editor
PropertyField("m_YAxisIndex"); PropertyField("m_YAxisIndex");
} }
PropertyField("m_LineType"); PropertyField("m_LineType");
//PropertyField("m_Clip");
PropertyFiledMore(() => PropertyFiledMore(() =>
{ {
PropertyFieldLimitMin("m_MinShow", 0); PropertyFieldLimitMin("m_MinShow", 0);
@@ -32,7 +33,6 @@ namespace XCharts.Editor
PropertyField("m_ShowAsPositiveNumber"); PropertyField("m_ShowAsPositiveNumber");
PropertyField("m_Large"); PropertyField("m_Large");
PropertyField("m_LargeThreshold"); PropertyField("m_LargeThreshold");
PropertyField("m_Clip");
}); });
PropertyField("m_Symbol"); PropertyField("m_Symbol");
PropertyField("m_LineStyle"); PropertyField("m_LineStyle");

View File

@@ -12,6 +12,7 @@ namespace XCharts.Editor
PropertyField("m_YAxisIndex"); PropertyField("m_YAxisIndex");
PropertyField("m_BarWidth"); PropertyField("m_BarWidth");
PropertyField("m_BarGap"); PropertyField("m_BarGap");
PropertyField("m_Clip");
PropertyField("m_ItemStyle"); PropertyField("m_ItemStyle");
PropertyField("m_Animation"); PropertyField("m_Animation");
} }

View File

@@ -10,6 +10,7 @@ namespace XCharts.Editor
PropertyField("m_XAxisIndex"); PropertyField("m_XAxisIndex");
PropertyField("m_YAxisIndex"); PropertyField("m_YAxisIndex");
PropertyField("m_LineType"); PropertyField("m_LineType");
//PropertyField("m_Clip");
PropertyField("m_LineStyle"); PropertyField("m_LineStyle");
PropertyField("m_ItemStyle"); PropertyField("m_ItemStyle");
PropertyField("m_Animation"); PropertyField("m_Animation");

View File

@@ -10,6 +10,8 @@ namespace XCharts.Runtime
public Orient orient; public Orient orient;
public float x; public float x;
public float y; public float y;
public float zeroX;
public float zeroY;
public float width; public float width;
public float height; public float height;
public Vector3 position; public Vector3 position;

View File

@@ -166,6 +166,10 @@ namespace XCharts
: (float)(Math.Abs(axis.context.minValue) * (grid.context.width : (float)(Math.Abs(axis.context.minValue) * (grid.context.width
/ (Math.Abs(axis.context.minValue) + Math.Abs(axis.context.maxValue)))) / (Math.Abs(axis.context.minValue) + Math.Abs(axis.context.maxValue))))
); );
axis.context.x = grid.context.x;
axis.context.y = grid.context.y;
axis.context.zeroY = grid.context.y;
axis.context.zeroX = grid.context.x - (float)(axis.context.minValue * grid.context.width / axis.context.minMaxRange);
} }
if (grid != null && axis is YAxis && axis.IsValue()) if (grid != null && axis is YAxis && axis.IsValue())
{ {
@@ -176,6 +180,10 @@ namespace XCharts
: (float)(Math.Abs(axis.context.minValue) * (grid.context.height : (float)(Math.Abs(axis.context.minValue) * (grid.context.height
/ (Math.Abs(axis.context.minValue) + Math.Abs(axis.context.maxValue)))) / (Math.Abs(axis.context.minValue) + Math.Abs(axis.context.maxValue))))
); );
axis.context.x = grid.context.x;
axis.context.y = grid.context.y;
axis.context.zeroX = grid.context.x;
axis.context.zeroY = grid.context.y - (float)(axis.context.minValue * grid.context.height / axis.context.minMaxRange);
} }
} }
var dataZoom = chart.GetDataZoomOfAxis(axis); var dataZoom = chart.GetDataZoomOfAxis(axis);

View File

@@ -511,7 +511,7 @@ namespace XCharts.Runtime
} }
/// <summary> /// <summary>
/// 获得数值value在坐标轴上对的长度 /// 获得数值value在坐标轴上对的长度
/// </summary> /// </summary>
/// <param name="grid"></param> /// <param name="grid"></param>
/// <param name="axis"></param> /// <param name="axis"></param>
@@ -549,10 +549,10 @@ namespace XCharts.Runtime
var yDataHig = 0f; var yDataHig = 0f;
if (axis.context.minMaxRange != 0) if (axis.context.minMaxRange != 0)
{ {
if (!realLength || (realLength && axis.context.minValue > 0)) if (realLength)
yDataHig = (float)((value - axis.context.minValue) / axis.context.minMaxRange * gridHeight); yDataHig = (float)(value * gridHeight / axis.context.minMaxRange);
else else
yDataHig = (float)(value / axis.context.minMaxRange * gridHeight); yDataHig = (float)((value - axis.context.minValue) / axis.context.minMaxRange * gridHeight);
} }
return includeGridXY return includeGridXY
? gridXY + yDataHig ? gridXY + yDataHig

View File

@@ -190,7 +190,7 @@ namespace XCharts.Runtime
var pY = 0f; var pY = 0f;
UpdateXYPosition(m_SerieGrid, isY, axis, relativedAxis, i, categoryWidth, barWidth, value, ref pX, ref pY); UpdateXYPosition(m_SerieGrid, isY, axis, relativedAxis, i, categoryWidth, barWidth, value, ref pX, ref pY);
var barHig = AxisHelper.GetAxisValueDistance(m_SerieGrid, relativedAxis, categoryWidth, relativedValue); var barHig = AxisHelper.GetAxisValueLength(m_SerieGrid, relativedAxis, categoryWidth, relativedValue);
var currHig = AnimationStyleHelper.CheckDataAnimation(chart, serie, i, barHig); var currHig = AnimationStyleHelper.CheckDataAnimation(chart, serie, i, barHig);
Vector3 plb, plt, prt, prb, top; Vector3 plb, plt, prt, prb, top;