void updateIndicator() { if (series1.getPoints().Count == 0) { return; } WMG_Node lastPoint = series1.getLastPoint().GetComponent <WMG_Node>(); graph.changeSpritePositionToY(indicatorGO, lastPoint.transform.localPosition.y); Vector2 nodeData = series1.getNodeValue(lastPoint); //indicatorLabelNumberFormatInfo.CurrencyDecimalDigits = indicatorNumDecimals; string textToSet = nodeData.y.ToString(); graph.changeLabelText(indicatorGO.transform.GetChild(0).GetChild(0).gameObject, textToSet); }
void blinkCurrentPointAnimation(bool fromOnCompleteAnimateAdd = false) { graph.Refresh(); // Ensures gamobject list of series points is up to date based on pointValues WMG_Node lastPoint = series1.getLastPoint().GetComponent <WMG_Node>(); string blinkingPointAnimId = series1.GetHashCode() + "blinkingPointAnim"; DOTween.Kill(blinkingPointAnimId); blinkingTween = lastPoint.objectToScale.transform.DOScale(new Vector3(blinkScale, blinkScale, blinkScale), blinkAnimDuration).SetEase(plotEaseType) .SetUpdate(false).SetId(blinkingPointAnimId).SetLoops(-1, LoopType.Yoyo); if (series1.pointValues.Count > 1) // ensure previous point scale reset { WMG_Node blinkingNode = series1.getPoints()[series1.getPoints().Count - 2].GetComponent <WMG_Node>(); if (fromOnCompleteAnimateAdd) // removing a pointValues index deletes the gameobject at the end, so need to set the timeline from the previous tween { blinkingTween.Goto(blinkAnimDuration * blinkingNode.objectToScale.transform.localScale.x / blinkScale, true); } blinkingNode.objectToScale.transform.localScale = Vector3.one; } }
private void animateLinkCallback(WMG_Series aSeries, GameObject aGO) { WMG_Node aNode = aGO.GetComponent<WMG_Node>(); WMG_Link theLine = aNode.links[aNode.links.Count-1].GetComponent<WMG_Link>(); theLine.Reposition(); if (aSeries.connectFirstToLast) { // One extra link to animate for circles / close loop series aNode = aSeries.getPoints()[0].GetComponent<WMG_Node>(); theLine = aNode.links[0].GetComponent<WMG_Link>(); theLine.Reposition(); } }
private void SeriesDataChangedMethod(WMG_Series aSeries) { // Animate the points, links, and bars List<GameObject> objects = aSeries.getPoints(); for (int i = 0; i < objects.Count; i++) { if (theGraph.graphType == WMG_Axis_Graph.graphTypes.line) { // For line graphs, need to animate links as well via callback functions GameObject go = objects[i]; // otherwise causes warnings when used in lambda expression for DOTween callback WMG_Anim.animPositionCallbacks(objects[i], theGraph.autoAnimationsDuration, theGraph.autoAnimationsEasetype, new Vector3(aSeries.AfterPositions()[i].x, aSeries.AfterPositions()[i].y), ()=> animateLinkCallback(aSeries, go), ()=> animateLinkCallbackEnd(aSeries)); } else { // For bar graphs, animate widths and heights in addition to position. Depending on pivot / GUI system, animating width / height also affects position Vector2 newPos = theGraph.getChangeSpritePositionTo(objects[i], new Vector2(aSeries.AfterPositions()[i].x, aSeries.AfterPositions()[i].y)); WMG_Anim.animPosition(objects[i], theGraph.autoAnimationsDuration, theGraph.autoAnimationsEasetype, new Vector3(newPos.x, newPos.y)); WMG_Anim.animSize(objects[i], theGraph.autoAnimationsDuration, theGraph.autoAnimationsEasetype, new Vector2(aSeries.AfterWidths()[i], aSeries.AfterHeights()[i])); } } // Animate the data point labels List<GameObject> dataLabels = aSeries.getDataLabels(); for (int i = 0; i < dataLabels.Count; i++) { if (theGraph.graphType == WMG_Axis_Graph.graphTypes.line) { float newX = aSeries.dataLabelsOffset.x; float newY = aSeries.dataLabelsOffset.y; Vector2 newPos = theGraph.getChangeSpritePositionTo(dataLabels[i], new Vector2(newX, newY)); newPos = new Vector2(newPos.x + aSeries.AfterPositions()[i].x + theGraph.getSpriteOffsetX(objects[i]), newPos.y + aSeries.AfterPositions()[i].y + theGraph.getSpriteOffsetY(objects[i])); WMG_Anim.animPosition(dataLabels[i], theGraph.autoAnimationsDuration, theGraph.autoAnimationsEasetype, new Vector3(newPos.x, newPos.y)); } else { float newY = aSeries.dataLabelsOffset.y + aSeries.AfterPositions()[i].y + theGraph.barWidth / 2; float newX = aSeries.dataLabelsOffset.x + aSeries.AfterPositions()[i].x + aSeries.AfterWidths()[i]; if (aSeries.getBarIsNegative(i)) { newX = -aSeries.dataLabelsOffset.x - aSeries.AfterWidths()[i] + Mathf.RoundToInt((theGraph.barAxisValue - theGraph.xAxisMinValue) / (theGraph.xAxisMaxValue - theGraph.xAxisMinValue) * theGraph.xAxisLength); } if (theGraph.orientationType == WMG_Axis_Graph.orientationTypes.vertical) { newY = aSeries.dataLabelsOffset.y + aSeries.AfterPositions()[i].y + aSeries.AfterHeights()[i]; newX = aSeries.dataLabelsOffset.x + aSeries.AfterPositions()[i].x + theGraph.barWidth / 2; if (aSeries.getBarIsNegative(i)) { newY = -aSeries.dataLabelsOffset.y - aSeries.AfterHeights()[i] + Mathf.RoundToInt((theGraph.barAxisValue - theGraph.yAxisMinValue) / (theGraph.yAxisMaxValue - theGraph.yAxisMinValue) * theGraph.yAxisLength); } } Vector2 newPos = theGraph.getChangeSpritePositionTo(dataLabels[i], new Vector2(newX, newY)); WMG_Anim.animPosition(dataLabels[i], theGraph.autoAnimationsDuration, theGraph.autoAnimationsEasetype, new Vector3(newPos.x, newPos.y)); } } }
private void animateLinkCallback(WMG_Series aSeries, GameObject aGO) { WMG_Node aNode = aGO.GetComponent <WMG_Node>(); WMG_Link theLine = aNode.links[aNode.links.Count - 1].GetComponent <WMG_Link>(); theLine.Reposition(); if (aSeries.connectFirstToLast) // One extra link to animate for circles / close loop series { aNode = aSeries.getPoints()[0].GetComponent <WMG_Node>(); theLine = aNode.links[0].GetComponent <WMG_Link>(); theLine.Reposition(); } }
private void animateLinkCallback(WMG_Series aSeries, GameObject aGO, bool isLast) { WMG_Node aNode = aGO.GetComponent<WMG_Node>(); if (aNode.links.Count != 0) { WMG_Link theLine = aNode.links[aNode.links.Count-1].GetComponent<WMG_Link>(); theLine.Reposition(); } if (isLast) { aSeries.updateAreaShading(null); } if (aSeries.connectFirstToLast) { // One extra link to animate for circles / close loop series aNode = aSeries.getPoints()[0].GetComponent<WMG_Node>(); WMG_Link theLine = aNode.links[0].GetComponent<WMG_Link>(); theLine.Reposition(); } }
void updateLabels() { if (labelsChanged || graphChanged) { if (!createdLabels) { WMG_Series labels = theGraph.addSeriesAt(numDataSeries + numGrids); labels.hideLines = true; createdLabels = true; labels.pointPrefab = 3; radarLabels = labels; StartCoroutine(invalidateCacheAfterAFrame()); } for (int i = 0; i < numPoints; i++) { if (labelStrings.Count <= i) { labelStrings.Add(""); } } for (int i = labelStrings.Count - 1; i >= 0; i--) { if (labelStrings[i] != null && i >= numPoints) { labelStrings.RemoveAt(i); } } radarLabels.hidePoints = hideLabels; radarLabels.pointValues = theGraph.GenCircular2(numPoints, offset.x, offset.y, labelsOffset + (radarMaxVal - radarMinVal), degreeOffset); List <GameObject> labelGOs = radarLabels.getPoints(); for (int i = 0; i < labelGOs.Count; i++) { if (i >= numPoints) { break; } theGraph.changeLabelFontSize(labelGOs[i], fontSize); theGraph.changeLabelText(labelGOs[i], labelStrings[i]); } radarLabels.pointColor = labelsColor; } }
void updateLabels() { if (!createdLabels) { WMG_Series labels = addSeriesAt(numDataSeries + numGrids); labels.hideLines = true; createdLabels = true; labels.pointPrefab = 3; radarLabels = labels; } for (int i = 0; i < numPoints; i++) { if (labelStrings.Count <= i) { labelStrings.AddNoCb("", ref _labelStrings); } } for (int i = labelStrings.Count - 1; i >= 0; i--) { if (labelStrings[i] != null && i >= numPoints) { labelStrings.RemoveAtNoCb(i, ref _labelStrings); } } radarLabels.hidePoints = hideLabels; radarLabels.pointValues.SetList(WMG_Util.GenCircular(numPoints, offset.x, offset.y, labelsOffset + (radarMaxVal - radarMinVal), degreeOffset)); List <GameObject> labelGOs = radarLabels.getPoints(); for (int i = 0; i < labelGOs.Count; i++) { if (i >= numPoints) { break; } changeLabelFontSize(labelGOs[i], fontSize); changeLabelText(labelGOs[i], labelStrings[i]); } radarLabels.pointColor = labelsColor; }
private void SeriesDataChangedMethod(WMG_Series aSeries) { // Animate the points, links, and bars List <GameObject> objects = aSeries.getPoints(); for (int i = 0; i < objects.Count; i++) { if (aSeries.seriesIsLine) { // For line graphs, need to animate links as well via callback functions GameObject go = objects[i]; // otherwise causes warnings when used in lambda expression for DOTween callback string tweenID = aSeries.GetHashCode() + "autoAnim" + i; // if (aSeries.name == "Series1") { // if (i == objects.Count-1) { // GlobalVariableBackground.Instance.conManager.WriteLog("curX: " + go.transform.localPosition.x + " curY: " + go.transform.localPosition.y); // GlobalVariableBackground.Instance.conManager.WriteLog("x: " + aSeries.AfterPositions()[i].x + " y: " + aSeries.AfterPositions()[i].y); // StartCoroutine(test (go)); // } // } bool isLast = (i == objects.Count - 1); if (aSeries.currentlyAnimating) { DOTween.Kill(tweenID); animateLinkCallback(aSeries, go, isLast); } WMG_Anim.animPositionCallbacks(go, theGraph.autoAnimationsDuration, theGraph.autoAnimationsEasetype, new Vector3(aSeries.AfterPositions()[i].x, aSeries.AfterPositions()[i].y), () => animateLinkCallback(aSeries, go, isLast), () => animateLinkCallbackEnd(aSeries, isLast), tweenID); } else { // For bar graphs, animate widths and heights in addition to position. Depending on pivot / GUI system, animating width / height also affects position Vector2 newPos = theGraph.getChangeSpritePositionTo(objects[i], new Vector2(aSeries.AfterPositions()[i].x, aSeries.AfterPositions()[i].y)); WMG_Anim.animPosition(objects[i], theGraph.autoAnimationsDuration, theGraph.autoAnimationsEasetype, new Vector3(newPos.x, newPos.y)); WMG_Anim.animSize(objects[i], theGraph.autoAnimationsDuration, theGraph.autoAnimationsEasetype, new Vector2(aSeries.AfterWidths()[i], aSeries.AfterHeights()[i])); } } // Animate the data point labels List <GameObject> dataLabels = aSeries.getDataLabels(); for (int i = 0; i < dataLabels.Count; i++) { if (aSeries.seriesIsLine) { float newX = aSeries.dataLabelsOffset.x; float newY = aSeries.dataLabelsOffset.y; Vector2 newPos = theGraph.getChangeSpritePositionTo(dataLabels[i], new Vector2(newX, newY)); newPos = new Vector2(newPos.x + aSeries.AfterPositions()[i].x, newPos.y + aSeries.AfterPositions()[i].y); WMG_Anim.animPosition(dataLabels[i], theGraph.autoAnimationsDuration, theGraph.autoAnimationsEasetype, new Vector3(newPos.x, newPos.y)); } else { float newY = aSeries.dataLabelsOffset.y + aSeries.AfterPositions()[i].y + theGraph.barWidth / 2; float newX = aSeries.dataLabelsOffset.x + aSeries.AfterPositions()[i].x + aSeries.AfterWidths()[i]; if (aSeries.getBarIsNegative(i)) { newX = -aSeries.dataLabelsOffset.x - aSeries.AfterWidths()[i] + Mathf.RoundToInt((theGraph.barAxisValue - theGraph.xAxis.AxisMinValue) / (theGraph.xAxis.AxisMaxValue - theGraph.xAxis.AxisMinValue) * theGraph.xAxisLength); } if (theGraph.orientationType == WMG_Axis_Graph.orientationTypes.vertical) { newY = aSeries.dataLabelsOffset.y + aSeries.AfterPositions()[i].y + aSeries.AfterHeights()[i]; newX = aSeries.dataLabelsOffset.x + aSeries.AfterPositions()[i].x + theGraph.barWidth / 2; if (aSeries.getBarIsNegative(i)) { newY = -aSeries.dataLabelsOffset.y - aSeries.AfterHeights()[i] + Mathf.RoundToInt((theGraph.barAxisValue - theGraph.yAxis.AxisMinValue) / (theGraph.yAxis.AxisMaxValue - theGraph.yAxis.AxisMinValue) * theGraph.yAxisLength); } } Vector2 newPos = theGraph.getChangeSpritePositionTo(dataLabels[i], new Vector2(newX, newY)); WMG_Anim.animPosition(dataLabels[i], theGraph.autoAnimationsDuration, theGraph.autoAnimationsEasetype, new Vector3(newPos.x, newPos.y)); } } if (!aSeries.currentlyAnimating) { aSeries.currentlyAnimating = true; } }
private void SeriesDataChangedMethod(WMG_Series aSeries) { // Animate the points, links, and bars List<GameObject> objects = aSeries.getPoints(); for (int i = 0; i < objects.Count; i++) { if (aSeries.seriesIsLine) { // For line graphs, need to animate links as well via callback functions GameObject go = objects[i]; // otherwise causes warnings when used in lambda expression for DOTween callback string tweenID = aSeries.GetHashCode() + "autoAnim" + i; // if (aSeries.name == "Series1") { // if (i == objects.Count-1) { // Debug.Log("curX: " + go.transform.localPosition.x + " curY: " + go.transform.localPosition.y); // Debug.Log("x: " + aSeries.AfterPositions()[i].x + " y: " + aSeries.AfterPositions()[i].y); // StartCoroutine(test (go)); // } // } if (aSeries.currentlyAnimating) { DOTween.Kill(tweenID); animateLinkCallback(aSeries, go); } WMG_Anim.animPositionCallbacks(go, theGraph.autoAnimationsDuration, theGraph.autoAnimationsEasetype, new Vector3(aSeries.AfterPositions()[i].x, aSeries.AfterPositions()[i].y), ()=> animateLinkCallback(aSeries, go), ()=> animateLinkCallbackEnd(aSeries), tweenID); } else { // For bar graphs, animate widths and heights in addition to position. Depending on pivot / GUI system, animating width / height also affects position Vector2 newPos = theGraph.getChangeSpritePositionTo(objects[i], new Vector2(aSeries.AfterPositions()[i].x, aSeries.AfterPositions()[i].y)); WMG_Anim.animPosition(objects[i], theGraph.autoAnimationsDuration, theGraph.autoAnimationsEasetype, new Vector3(newPos.x, newPos.y)); WMG_Anim.animSize(objects[i], theGraph.autoAnimationsDuration, theGraph.autoAnimationsEasetype, new Vector2(aSeries.AfterWidths()[i], aSeries.AfterHeights()[i])); } } // Animate the data point labels List<GameObject> dataLabels = aSeries.getDataLabels(); for (int i = 0; i < dataLabels.Count; i++) { if (aSeries.seriesIsLine) { float newX = aSeries.dataLabelsOffset.x; float newY = aSeries.dataLabelsOffset.y; Vector2 newPos = theGraph.getChangeSpritePositionTo(dataLabels[i], new Vector2(newX, newY)); newPos = new Vector2(newPos.x + aSeries.AfterPositions()[i].x, newPos.y + aSeries.AfterPositions()[i].y); WMG_Anim.animPosition(dataLabels[i], theGraph.autoAnimationsDuration, theGraph.autoAnimationsEasetype, new Vector3(newPos.x, newPos.y)); } else { float newY = aSeries.dataLabelsOffset.y + aSeries.AfterPositions()[i].y + theGraph.barWidth / 2; float newX = aSeries.dataLabelsOffset.x + aSeries.AfterPositions()[i].x + aSeries.AfterWidths()[i]; if (aSeries.getBarIsNegative(i)) { newX = -aSeries.dataLabelsOffset.x - aSeries.AfterWidths()[i] + Mathf.RoundToInt((theGraph.barAxisValue - theGraph.xAxis.AxisMinValue) / (theGraph.xAxis.AxisMaxValue - theGraph.xAxis.AxisMinValue) * theGraph.xAxisLength); } if (theGraph.orientationType == WMG_Axis_Graph.orientationTypes.vertical) { newY = aSeries.dataLabelsOffset.y + aSeries.AfterPositions()[i].y + aSeries.AfterHeights()[i]; newX = aSeries.dataLabelsOffset.x + aSeries.AfterPositions()[i].x + theGraph.barWidth / 2; if (aSeries.getBarIsNegative(i)) { newY = -aSeries.dataLabelsOffset.y - aSeries.AfterHeights()[i] + Mathf.RoundToInt((theGraph.barAxisValue - theGraph.yAxis.AxisMinValue) / (theGraph.yAxis.AxisMaxValue - theGraph.yAxis.AxisMinValue) * theGraph.yAxisLength); } } Vector2 newPos = theGraph.getChangeSpritePositionTo(dataLabels[i], new Vector2(newX, newY)); WMG_Anim.animPosition(dataLabels[i], theGraph.autoAnimationsDuration, theGraph.autoAnimationsEasetype, new Vector3(newPos.x, newPos.y)); } } if (!aSeries.currentlyAnimating) { aSeries.currentlyAnimating = true; } }
private void SeriesDataChangedMethod(WMG_Series aSeries) { // Animate the points, links, and bars List <GameObject> objects = aSeries.getPoints(); for (int i = 0; i < objects.Count; i++) { if (theGraph.graphType == WMG_Axis_Graph.graphTypes.line) { // For line graphs, need to animate links as well via callback functions GameObject go = objects[i]; // otherwise causes warnings when used in lambda expression for DOTween callback string tweenId = "seriesAutoAnim" + i; WMG_Anim.animPositionCallbacks(objects[i], theGraph.autoAnimationsDuration, theGraph.autoAnimationsEasetype, new Vector3(aSeries.AfterPositions()[i].x, aSeries.AfterPositions()[i].y), () => animateLinkCallback(aSeries, go), () => animateLinkCallbackEnd(aSeries), tweenId); } else { // For bar graphs, animate widths and heights in addition to position. Depending on pivot / GUI system, animating width / height also affects position Vector2 newPos = theGraph.getChangeSpritePositionTo(objects[i], new Vector2(aSeries.AfterPositions()[i].x, aSeries.AfterPositions()[i].y)); WMG_Anim.animPosition(objects[i], theGraph.autoAnimationsDuration, theGraph.autoAnimationsEasetype, new Vector3(newPos.x, newPos.y)); WMG_Anim.animSize(objects[i], theGraph.autoAnimationsDuration, theGraph.autoAnimationsEasetype, new Vector2(aSeries.AfterWidths()[i], aSeries.AfterHeights()[i])); } } // Animate the data point labels List <GameObject> dataLabels = aSeries.getDataLabels(); for (int i = 0; i < dataLabels.Count; i++) { if (theGraph.graphType == WMG_Axis_Graph.graphTypes.line) { float newX = aSeries.dataLabelsOffset.x; float newY = aSeries.dataLabelsOffset.y; Vector2 newPos = theGraph.getChangeSpritePositionTo(dataLabels[i], new Vector2(newX, newY)); newPos = new Vector2(newPos.x + aSeries.AfterPositions()[i].x + theGraph.getSpriteOffsetX(objects[i]), newPos.y + aSeries.AfterPositions()[i].y + theGraph.getSpriteOffsetY(objects[i])); WMG_Anim.animPosition(dataLabels[i], theGraph.autoAnimationsDuration, theGraph.autoAnimationsEasetype, new Vector3(newPos.x, newPos.y)); } else { float newY = aSeries.dataLabelsOffset.y + aSeries.AfterPositions()[i].y + theGraph.barWidth / 2; float newX = aSeries.dataLabelsOffset.x + aSeries.AfterPositions()[i].x + aSeries.AfterWidths()[i]; if (aSeries.getBarIsNegative(i)) { newX = -aSeries.dataLabelsOffset.x - aSeries.AfterWidths()[i] + Mathf.RoundToInt((theGraph.barAxisValue - theGraph.xAxisMinValue) / (theGraph.xAxisMaxValue - theGraph.xAxisMinValue) * theGraph.xAxisLength); } if (theGraph.orientationType == WMG_Axis_Graph.orientationTypes.vertical) { newY = aSeries.dataLabelsOffset.y + aSeries.AfterPositions()[i].y + aSeries.AfterHeights()[i]; newX = aSeries.dataLabelsOffset.x + aSeries.AfterPositions()[i].x + theGraph.barWidth / 2; if (aSeries.getBarIsNegative(i)) { newY = -aSeries.dataLabelsOffset.y - aSeries.AfterHeights()[i] + Mathf.RoundToInt((theGraph.barAxisValue - theGraph.yAxisMinValue) / (theGraph.yAxisMaxValue - theGraph.yAxisMinValue) * theGraph.yAxisLength); } } Vector2 newPos = theGraph.getChangeSpritePositionTo(dataLabels[i], new Vector2(newX, newY)); WMG_Anim.animPosition(dataLabels[i], theGraph.autoAnimationsDuration, theGraph.autoAnimationsEasetype, new Vector3(newPos.x, newPos.y)); } } }