mirror of
https://github.com/XCharts-Team/XCharts.git
synced 2026-05-23 09:20:08 +00:00
增加Line支持X轴和Y轴都为Category类目轴
This commit is contained in:
@@ -305,7 +305,7 @@ namespace XCharts.Runtime
|
||||
{
|
||||
GetSerieDataByXYAxis(serie, xAxis, yAxis);
|
||||
}
|
||||
else if (yAxis.IsCategory())
|
||||
else if (yAxis.IsCategory() && !xAxis.IsCategory())
|
||||
{
|
||||
if (isTriggerAxis)
|
||||
{
|
||||
@@ -583,13 +583,17 @@ namespace XCharts.Runtime
|
||||
|
||||
private bool IsYCategoryOfGrid(int gridIndex)
|
||||
{
|
||||
var yAxes = chart.GetChartComponents<YAxis>();
|
||||
foreach (var component in yAxes)
|
||||
foreach (var component in chart.GetChartComponents<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)
|
||||
|
||||
@@ -459,13 +459,14 @@ namespace XCharts.Runtime
|
||||
internal bool GetSerieGridCoordAxis(Serie serie, out Axis axis, out Axis relativedAxis)
|
||||
{
|
||||
var yAxis = GetChartComponent<YAxis>(serie.yAxisIndex);
|
||||
if (yAxis == null)
|
||||
var xAxis = GetChartComponent<XAxis>(serie.xAxisIndex);
|
||||
if (xAxis == null || yAxis == null)
|
||||
{
|
||||
axis = null;
|
||||
relativedAxis = null;
|
||||
return false;
|
||||
}
|
||||
var isY = yAxis.IsCategory();
|
||||
var isY = yAxis.IsCategory() && !xAxis.IsCategory();
|
||||
if (isY)
|
||||
{
|
||||
axis = yAxis;
|
||||
|
||||
@@ -277,6 +277,7 @@ namespace XCharts.Runtime
|
||||
return;
|
||||
|
||||
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 ?
|
||||
@@ -284,6 +285,7 @@ namespace XCharts.Runtime
|
||||
showData.Count;
|
||||
maxCount -= serie.context.dataZoomStartIndexOffset;
|
||||
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);
|
||||
var totalAverage = serie.sampleAverage > 0 ?
|
||||
serie.sampleAverage :
|
||||
@@ -330,7 +332,7 @@ namespace XCharts.Runtime
|
||||
maxCount, totalAverage, i, 0, dataChangeDuration, ref dataChanging, relativedAxis, unscaledTime);
|
||||
|
||||
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;
|
||||
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,
|
||||
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;
|
||||
var gridXY = isY ? grid.context.x : grid.context.y;
|
||||
var valueHig = 0f;
|
||||
valueHig = AxisHelper.GetAxisValueDistance(grid, relativedAxis, scaleWid, yValue);
|
||||
valueHig = AxisHelper.GetAxisValueDistance(grid, relativedAxis, scaleRelativedWid, yValue);
|
||||
valueHig = AnimationStyleHelper.CheckDataAnimation(chart, serie, i, valueHig);
|
||||
if (isY)
|
||||
{
|
||||
@@ -399,7 +401,7 @@ namespace XCharts.Runtime
|
||||
}
|
||||
}
|
||||
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