public void UnitEnable(GameObject xPrefab, GameObject yPrefab, Rect rect, Transform parent, sgSettingBase baseSetting, BarChartSetting setting, BarChartData data) { Setting = setting; BaseSetting = baseSetting; Data = data; this.size = rect.size; this.origin = new Vector2(-size.x / 2.0f, -size.y / 2.0f); // x axis text Vector2 leftStart = origin + new Vector2(Setting.BarSpacing / 2.0f, 0); foreach (var bars in Data.BarDic) { for (int i = 0; i < bars.Value.Count; i++) // 4 bars { int count = bars.Value[i].bars.Count; Vector2 pos = leftStart + new Vector2(Setting.BarWidth * count, 0) / 2.0f + new Vector2(Setting.BarInterval * (count - 1), 0) / 2.0f + new Vector2(0, -5); GenerateUnit(xPrefab, parent, pos, BaseSetting.UnitXScale * i + BaseSetting.XUnit); leftStart = leftStart + new Vector2(Setting.BarSpacing, 0) + new Vector2(Setting.BarWidth * count, 0) + new Vector2(Setting.BarInterval * (count - 1), 0); } } // y axis text for (float i = 0, height = origin.y; height <= size.y / 2.0f; i++, height += BaseSetting.VerticalSpacing) { Vector2 pos = new Vector2(origin.x, height) + new Vector2(-5, 0); GenerateUnit(yPrefab, parent, pos, BaseSetting.UnitYScale * i + BaseSetting.YUnit); } }
public VertexHelper DrawBarChart(VertexHelper vh, Rect rect, sgSettingBase baseSetting, BarChartSetting barChartSetting, BarChartData data) { BaseSetting = baseSetting; Setting = barChartSetting; this.size = rect.size; this.origin = new Vector2(-size.x / 2.0f, -size.y / 2.0f); Data = data; DrawMesh(vh, rect); return(vh); }