void RestoreDataValues(int axis) { IInternalGraphData data = this; if (axis == 0) { double maxH = data.GetMaxValue(0, true); double minH = data.GetMinValue(0, true); horizontalViewOrigin = minH; horizontalViewSize = maxH - minH; } else { double maxV = data.GetMaxValue(1, true); double minV = data.GetMinValue(1, true); verticalViewOrigin = minV; verticalViewSize = maxV - minV; } }
public void Animate(string category, List <DoubleVector2> points, float totalTime) { graphChart = GetComponent <GraphChartBase>(); if (graphChart == null) { return; } if (points == null) { return; } if (points.Count == 0) { return; } InnerAnimation anim = new InnerAnimation(); anim.maxX = float.MinValue; anim.maxY = float.MinValue; anim.minX = float.MaxValue; anim.minY = float.MaxValue; for (int i = 0; i < points.Count; ++i) { anim.maxX = Math.Max(points[i].x, anim.maxX); anim.maxY = Math.Max(points[i].y, anim.maxY); anim.minX = Math.Min(points[i].x, anim.minX); anim.minY = Math.Min(points[i].y, anim.minY); } if (ModifyRange) { double maxX = anim.maxX; double maxY = anim.maxY; double minX = anim.minX; double minY = anim.minY; foreach (InnerAnimation a in mAnimations.Values) { maxX = Math.Max(maxX, a.maxX); maxY = Math.Max(maxY, a.maxY); minX = Math.Min(minX, a.minX); minY = Math.Min(minY, a.minY); } IInternalGraphData g = graphChart.DataSource; maxX = (float)Math.Max(g.GetMaxValue(0, true), maxX); minX = (float)Math.Min(g.GetMinValue(0, true), minX); maxY = (float)Math.Max(g.GetMaxValue(1, true), maxY); minY = (float)Math.Min(g.GetMinValue(1, true), minY); if (IsValidDouble(maxX) && IsValidDouble(maxY) && IsValidDouble(minX) && IsValidDouble(minY)) { graphChart.DataSource.StartBatch(); graphChart.DataSource.AutomaticHorizontalView = false; graphChart.DataSource.AutomaticVerticallView = false; graphChart.DataSource.HorizontalViewSize = (maxX - minX); graphChart.DataSource.HorizontalViewOrigin = minX; graphChart.DataSource.VerticalViewSize = (maxY - minY); graphChart.DataSource.VerticalViewOrigin = minY; graphChart.DataSource.EndBatch(); } } anim.points = points; anim.index = 0; anim.next = 0; anim.totalTime = totalTime; anim.category = category; graphChart.DataSource.ClearCategory(category); mAnimations[category] = anim; }