mirror of
https://github.com/XCharts-Team/XCharts.git
synced 2026-05-23 09:20:08 +00:00
尺寸自适应
This commit is contained in:
@@ -154,6 +154,8 @@ namespace xcharts
|
|||||||
lastCoordinateHig = chartHig;
|
lastCoordinateHig = chartHig;
|
||||||
lastCoordinateWid = chartWid;
|
lastCoordinateWid = chartWid;
|
||||||
lastCoordinateScaleLen = coordinate.splitWidth;
|
lastCoordinateScaleLen = coordinate.splitWidth;
|
||||||
|
checkXAxis = xAxis;
|
||||||
|
checkYAxis = yAxis;
|
||||||
InitXScale();
|
InitXScale();
|
||||||
InitYScale();
|
InitYScale();
|
||||||
}
|
}
|
||||||
@@ -363,6 +365,7 @@ namespace xcharts
|
|||||||
new Vector2(1, 0.5f),
|
new Vector2(1, 0.5f),
|
||||||
new Vector2(scaleWid, 20));
|
new Vector2(scaleWid, 20));
|
||||||
txt.transform.localPosition = GetXScalePosition(scaleWid, i);
|
txt.transform.localPosition = GetXScalePosition(scaleWid, i);
|
||||||
|
|
||||||
txt.text = xAxis.GetData(i, max);
|
txt.text = xAxis.GetData(i, max);
|
||||||
txt.gameObject.SetActive(coordinate.show);
|
txt.gameObject.SetActive(coordinate.show);
|
||||||
xScaleTextList.Add(txt);
|
xScaleTextList.Add(txt);
|
||||||
@@ -470,23 +473,8 @@ namespace xcharts
|
|||||||
|
|
||||||
protected virtual void OnCoordinateSize()
|
protected virtual void OnCoordinateSize()
|
||||||
{
|
{
|
||||||
//update yScale pos
|
InitXScale();
|
||||||
float yscaleWid = coordinateHig / (yAxis.GetSplitNumber() - 1);
|
InitYScale();
|
||||||
float xscaleWid = coordinateHig / (xAxis.GetSplitNumber() - 1);
|
|
||||||
for (int i = 0; i < yAxis.GetSplitNumber(); i++)
|
|
||||||
{
|
|
||||||
if (i < yScaleTextList.Count && yScaleTextList[i])
|
|
||||||
{
|
|
||||||
yScaleTextList[i].transform.localPosition = GetYScalePosition(yscaleWid,i);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (int i = 0; i < xAxis.GetSplitNumber(); i++)
|
|
||||||
{
|
|
||||||
if (i < xScaleTextList.Count && xScaleTextList[i])
|
|
||||||
{
|
|
||||||
xScaleTextList[i].transform.localPosition = GetXScalePosition(xscaleWid, i);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected virtual void OnYAxisChanged()
|
protected virtual void OnYAxisChanged()
|
||||||
@@ -510,6 +498,13 @@ namespace xcharts
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override void OnSizeChanged()
|
||||||
|
{
|
||||||
|
base.OnSizeChanged();
|
||||||
|
InitXScale();
|
||||||
|
InitYScale();
|
||||||
|
}
|
||||||
|
|
||||||
protected override void OnYMaxValueChanged()
|
protected override void OnYMaxValueChanged()
|
||||||
{
|
{
|
||||||
float max = GetMaxValue();
|
float max = GetMaxValue();
|
||||||
|
|||||||
@@ -249,6 +249,8 @@ namespace xcharts
|
|||||||
private Theme checkTheme = 0;
|
private Theme checkTheme = 0;
|
||||||
private Title checkTitle = new Title();
|
private Title checkTitle = new Title();
|
||||||
private Legend checkLegend = new Legend();
|
private Legend checkLegend = new Legend();
|
||||||
|
private float checkWid = 0;
|
||||||
|
private float checkHig = 0;
|
||||||
|
|
||||||
protected Text titleText;
|
protected Text titleText;
|
||||||
protected List<Text> legendTextList = new List<Text>();
|
protected List<Text> legendTextList = new List<Text>();
|
||||||
@@ -261,6 +263,9 @@ namespace xcharts
|
|||||||
rectTransform.anchorMax = Vector2.zero;
|
rectTransform.anchorMax = Vector2.zero;
|
||||||
rectTransform.anchorMin = Vector2.zero;
|
rectTransform.anchorMin = Vector2.zero;
|
||||||
rectTransform.pivot = Vector2.zero;
|
rectTransform.pivot = Vector2.zero;
|
||||||
|
checkWid = chartWid;
|
||||||
|
checkHig = chartHig;
|
||||||
|
checkTheme = theme;
|
||||||
InitTitle();
|
InitTitle();
|
||||||
InitLegend();
|
InitLegend();
|
||||||
InitTooltip();
|
InitTooltip();
|
||||||
@@ -268,6 +273,7 @@ namespace xcharts
|
|||||||
|
|
||||||
protected virtual void Update()
|
protected virtual void Update()
|
||||||
{
|
{
|
||||||
|
CheckSize();
|
||||||
CheckTheme();
|
CheckTheme();
|
||||||
CheckTile();
|
CheckTile();
|
||||||
CheckLegend();
|
CheckLegend();
|
||||||
@@ -472,6 +478,16 @@ namespace xcharts
|
|||||||
return bigger < 10 ? bigger : bigger - bigger % 10;
|
return bigger < 10 ? bigger : bigger - bigger % 10;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void CheckSize()
|
||||||
|
{
|
||||||
|
if(checkWid != chartWid || checkHig != chartHig)
|
||||||
|
{
|
||||||
|
checkWid = chartWid;
|
||||||
|
checkHig = chartHig;
|
||||||
|
OnSizeChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void CheckTheme()
|
private void CheckTheme()
|
||||||
{
|
{
|
||||||
if (checkTheme != theme)
|
if (checkTheme != theme)
|
||||||
@@ -549,6 +565,12 @@ namespace xcharts
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected virtual void OnSizeChanged()
|
||||||
|
{
|
||||||
|
InitTitle();
|
||||||
|
InitLegend();
|
||||||
|
}
|
||||||
|
|
||||||
protected virtual void OnThemeChanged()
|
protected virtual void OnThemeChanged()
|
||||||
{
|
{
|
||||||
switch (theme)
|
switch (theme)
|
||||||
|
|||||||
Reference in New Issue
Block a user