mirror of
https://github.com/XCharts-Team/XCharts.git
synced 2026-05-28 03:58:49 +00:00
增加Line支持X轴和Y轴都为Category类目轴
This commit is contained in:
@@ -305,7 +305,7 @@ namespace XCharts.Runtime
|
|||||||
{
|
{
|
||||||
GetSerieDataByXYAxis(serie, xAxis, yAxis);
|
GetSerieDataByXYAxis(serie, xAxis, yAxis);
|
||||||
}
|
}
|
||||||
else if (yAxis.IsCategory())
|
else if (yAxis.IsCategory() && !xAxis.IsCategory())
|
||||||
{
|
{
|
||||||
if (isTriggerAxis)
|
if (isTriggerAxis)
|
||||||
{
|
{
|
||||||
@@ -583,13 +583,17 @@ namespace XCharts.Runtime
|
|||||||
|
|
||||||
private bool IsYCategoryOfGrid(int gridIndex)
|
private bool IsYCategoryOfGrid(int gridIndex)
|
||||||
{
|
{
|
||||||
var yAxes = chart.GetChartComponents<YAxis>();
|
foreach (var component in chart.GetChartComponents<YAxis>())
|
||||||
foreach (var component in yAxes)
|
|
||||||
{
|
{
|
||||||
var yAxis = component as YAxis;
|
var yAxis = component as YAxis;
|
||||||
if (yAxis.gridIndex == gridIndex && yAxis.IsCategory()) return true;
|
if (yAxis.gridIndex == gridIndex && !yAxis.IsCategory()) return false;
|
||||||
}
|
}
|
||||||
return false;
|
foreach (var component in chart.GetChartComponents<XAxis>())
|
||||||
|
{
|
||||||
|
var xAxis = component as XAxis;
|
||||||
|
if (xAxis.gridIndex == gridIndex && xAxis.IsCategory()) return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void DrawXAxisIndicator(VertexHelper vh, Tooltip tooltip, GridCoord grid)
|
private void DrawXAxisIndicator(VertexHelper vh, Tooltip tooltip, GridCoord grid)
|
||||||
|
|||||||
@@ -459,13 +459,14 @@ namespace XCharts.Runtime
|
|||||||
internal bool GetSerieGridCoordAxis(Serie serie, out Axis axis, out Axis relativedAxis)
|
internal bool GetSerieGridCoordAxis(Serie serie, out Axis axis, out Axis relativedAxis)
|
||||||
{
|
{
|
||||||
var yAxis = GetChartComponent<YAxis>(serie.yAxisIndex);
|
var yAxis = GetChartComponent<YAxis>(serie.yAxisIndex);
|
||||||
if (yAxis == null)
|
var xAxis = GetChartComponent<XAxis>(serie.xAxisIndex);
|
||||||
|
if (xAxis == null || yAxis == null)
|
||||||
{
|
{
|
||||||
axis = null;
|
axis = null;
|
||||||
relativedAxis = null;
|
relativedAxis = null;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
var isY = yAxis.IsCategory();
|
var isY = yAxis.IsCategory() && !xAxis.IsCategory();
|
||||||
if (isY)
|
if (isY)
|
||||||
{
|
{
|
||||||
axis = yAxis;
|
axis = yAxis;
|
||||||
|
|||||||
@@ -277,6 +277,7 @@ namespace XCharts.Runtime
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
var axisLength = isY ? m_SerieGrid.context.height : m_SerieGrid.context.width;
|
var axisLength = isY ? m_SerieGrid.context.height : m_SerieGrid.context.width;
|
||||||
|
var axisRelativedLength = isY ? m_SerieGrid.context.width : m_SerieGrid.context.height;
|
||||||
|
|
||||||
|
|
||||||
int maxCount = serie.maxShow > 0 ?
|
int maxCount = serie.maxShow > 0 ?
|
||||||
@@ -284,6 +285,7 @@ namespace XCharts.Runtime
|
|||||||
showData.Count;
|
showData.Count;
|
||||||
maxCount -= serie.context.dataZoomStartIndexOffset;
|
maxCount -= serie.context.dataZoomStartIndexOffset;
|
||||||
var scaleWid = AxisHelper.GetDataWidth(axis, axisLength, maxCount, dataZoom);
|
var scaleWid = AxisHelper.GetDataWidth(axis, axisLength, maxCount, dataZoom);
|
||||||
|
var scaleRelativedWid = AxisHelper.GetDataWidth(relativedAxis, axisRelativedLength, maxCount, dataZoom);
|
||||||
int rate = LineHelper.GetDataAverageRate(serie, m_SerieGrid, maxCount, false);
|
int rate = LineHelper.GetDataAverageRate(serie, m_SerieGrid, maxCount, false);
|
||||||
var totalAverage = serie.sampleAverage > 0 ?
|
var totalAverage = serie.sampleAverage > 0 ?
|
||||||
serie.sampleAverage :
|
serie.sampleAverage :
|
||||||
@@ -330,7 +332,7 @@ namespace XCharts.Runtime
|
|||||||
maxCount, totalAverage, i, 0, dataChangeDuration, ref dataChanging, relativedAxis, unscaledTime);
|
maxCount, totalAverage, i, 0, dataChangeDuration, ref dataChanging, relativedAxis, unscaledTime);
|
||||||
|
|
||||||
serieData.context.stackHeight = GetDataPoint(isY, axis, relativedAxis, m_SerieGrid, xValue, relativedValue,
|
serieData.context.stackHeight = GetDataPoint(isY, axis, relativedAxis, m_SerieGrid, xValue, relativedValue,
|
||||||
i, scaleWid, isStack, ref np);
|
i, scaleWid, scaleRelativedWid, isStack, ref np);
|
||||||
serieData.context.isClip = false;
|
serieData.context.isClip = false;
|
||||||
if (serie.clip && !m_SerieGrid.Contains(np))
|
if (serie.clip && !m_SerieGrid.Contains(np))
|
||||||
{
|
{
|
||||||
@@ -371,12 +373,12 @@ namespace XCharts.Runtime
|
|||||||
}
|
}
|
||||||
|
|
||||||
private float GetDataPoint(bool isY, Axis axis, Axis relativedAxis, GridCoord grid, double xValue,
|
private float GetDataPoint(bool isY, Axis axis, Axis relativedAxis, GridCoord grid, double xValue,
|
||||||
double yValue, int i, float scaleWid, bool isStack, ref Vector3 np)
|
double yValue, int i, float scaleWid, float scaleRelativedWid, bool isStack, ref Vector3 np)
|
||||||
{
|
{
|
||||||
float xPos, yPos;
|
float xPos, yPos;
|
||||||
var gridXY = isY ? grid.context.x : grid.context.y;
|
var gridXY = isY ? grid.context.x : grid.context.y;
|
||||||
var valueHig = 0f;
|
var valueHig = 0f;
|
||||||
valueHig = AxisHelper.GetAxisValueDistance(grid, relativedAxis, scaleWid, yValue);
|
valueHig = AxisHelper.GetAxisValueDistance(grid, relativedAxis, scaleRelativedWid, yValue);
|
||||||
valueHig = AnimationStyleHelper.CheckDataAnimation(chart, serie, i, valueHig);
|
valueHig = AnimationStyleHelper.CheckDataAnimation(chart, serie, i, valueHig);
|
||||||
if (isY)
|
if (isY)
|
||||||
{
|
{
|
||||||
@@ -399,7 +401,7 @@ namespace XCharts.Runtime
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
np = new Vector3(xPos, yPos);
|
np = new Vector3(xPos, yPos);
|
||||||
return AxisHelper.GetAxisValueLength(grid, relativedAxis, scaleWid, yValue);
|
return AxisHelper.GetAxisValueLength(grid, relativedAxis, scaleRelativedWid, yValue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user