mirror of
https://github.com/XCharts-Team/XCharts.git
synced 2026-05-21 16:00:24 +00:00
增加Demo首页BarChart的代码动态控制效果
This commit is contained in:
@@ -185,6 +185,14 @@ namespace XCharts
|
||||
{
|
||||
RefreshDataZoomLabel();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 立即刷新数值坐标轴的最大最小值
|
||||
/// </summary>
|
||||
public void RefreshAxisMinMaxValue()
|
||||
{
|
||||
CheckMinMaxValue();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using UnityEngine;
|
||||
|
||||
namespace XCharts
|
||||
{
|
||||
|
||||
@@ -355,11 +355,11 @@ namespace XCharts
|
||||
/// <summary>
|
||||
/// 斑马线的粗细。
|
||||
/// </summary>
|
||||
public float barZebraWidth { get { return m_BarZebraWidth; } set { m_BarZebraWidth = value; } }
|
||||
public float barZebraWidth { get { return m_BarZebraWidth; } set { m_BarZebraWidth = value > 0 ? value : 0; } }
|
||||
/// <summary>
|
||||
/// 斑马线的间距。
|
||||
/// </summary>
|
||||
public float barZebraGap { get { return m_BarZebraGap; } set { m_BarZebraGap = value; } }
|
||||
public float barZebraGap { get { return m_BarZebraGap; } set { m_BarZebraGap = value > 0 ? value : 0; } }
|
||||
|
||||
/// <summary>
|
||||
/// Whether offset when mouse click pie chart item.
|
||||
|
||||
@@ -308,13 +308,15 @@ namespace XCharts
|
||||
var labelObj = ChartHelper.AddSerieLabel(textName, labelObject.transform, m_ThemeInfo.font,
|
||||
color, backgroundColor, serie.label.fontSize, serie.label.fontStyle, serie.label.rotate,
|
||||
serie.label.backgroundWidth, serie.label.backgroundHeight);
|
||||
|
||||
var iconObj = ChartHelper.AddIcon("Icon", labelObj.transform, serieData.iconWidth, serieData.iconHeight);
|
||||
serieData.SetIconObj(iconObj);
|
||||
|
||||
var isAutoSize = serie.label.backgroundWidth == 0 || serie.label.backgroundHeight == 0;
|
||||
serieData.InitLabel(labelObj, isAutoSize, serie.label.paddingLeftRight, serie.label.paddingTopBottom);
|
||||
serieData.SetLabelActive(false);
|
||||
serieData.SetLabelText(serieData.name);
|
||||
|
||||
var iconObj = ChartHelper.AddIcon("Icon", labelObj.transform, serieData.iconWidth, serieData.iconHeight);
|
||||
serieData.SetIconObj(iconObj);
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -756,7 +756,7 @@ namespace XCharts
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateAxisMinMaxValue(int axisIndex, Axis axis)
|
||||
private void UpdateAxisMinMaxValue(int axisIndex, Axis axis, bool updateChart = true)
|
||||
{
|
||||
if (axis.IsCategory() || !axis.show) return;
|
||||
int tempMinValue = 0;
|
||||
@@ -801,10 +801,13 @@ namespace XCharts
|
||||
Mathf.Abs(axis.minValue) * (coordinateHeight / (Mathf.Abs(axis.minValue) + Mathf.Abs(axis.maxValue)));
|
||||
}
|
||||
}
|
||||
float coordinateWidth = axis is XAxis ? this.coordinateWidth : coordinateHeight;
|
||||
var isPercentStack = m_Series.IsPercentStack(SerieType.Bar);
|
||||
axis.UpdateLabelText(coordinateWidth, m_DataZoom, isPercentStack);
|
||||
RefreshChart();
|
||||
if (updateChart)
|
||||
{
|
||||
float coordinateWidth = axis is XAxis ? this.coordinateWidth : coordinateHeight;
|
||||
var isPercentStack = m_Series.IsPercentStack(SerieType.Bar);
|
||||
axis.UpdateLabelText(coordinateWidth, m_DataZoom, isPercentStack);
|
||||
RefreshChart();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1377,7 +1380,7 @@ namespace XCharts
|
||||
var content = "";
|
||||
if (anyPercentStack && isPercentStack)
|
||||
{
|
||||
var tempTotal = GetSameStackTotalValue(serie.stack,j);
|
||||
var tempTotal = GetSameStackTotalValue(serie.stack, j);
|
||||
content = serie.label.GetFormatterContent(serie.name, serieData.name, value, tempTotal);
|
||||
}
|
||||
else
|
||||
|
||||
@@ -124,6 +124,7 @@ namespace XCharts
|
||||
var yAxis = m_YAxises[serie.axisIndex];
|
||||
var xAxis = m_XAxises[serie.axisIndex];
|
||||
if (!xAxis.show) xAxis = m_XAxises[(serie.axisIndex + 1) % m_XAxises.Count];
|
||||
|
||||
float categoryWidth = xAxis.GetDataWidth(coordinateWidth, m_DataZoom);
|
||||
float barGap = GetBarGap();
|
||||
float totalBarWidth = GetBarTotalWidth(categoryWidth, barGap);
|
||||
@@ -142,6 +143,7 @@ namespace XCharts
|
||||
seriesHig.Add(0);
|
||||
}
|
||||
}
|
||||
|
||||
var isPercentStack = m_Series.IsPercentStack(serie.stack, SerieType.Bar);
|
||||
for (int i = serie.minShow; i < maxCount; i++)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user