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