Ejemplo n.º 1
0
 public void animBandFill(int ringNum, float endFill)
 {
     if (!graph.bandMode)
     {
         return;
     }
     if (!graph.useComputeShader)
     {
         WMG_Anim.animFill(band, graph.animDuration, graph.animEaseType, endFill);
     }
     else
     {
         animTimeline = 0;
         WMG_Anim.animFloatCallbackU(() => animTimeline, x => animTimeline = x, graph.animDuration, 1,
                                     () => onUpdateAnimateBandFill(ringNum, endFill), graph.animEaseType);
     }
     if (graph.pieMode)
     {
         WMG_Anim.animFill(interactibleObj, graph.animDuration, graph.animEaseType, endFill);
     }
 }
Ejemplo n.º 2
0
 void myPieSliceHoverFunction(WMG_Pie_Graph pieGraph, WMG_Pie_Graph_Slice aSlice, bool hover)
 {
     Debug.Log("Pie Slice Hover: " + pieGraph.sliceLabels[aSlice.sliceIndex]);
     if (hover)
     {
         Vector3 newPos = graph.getPositionFromExplode(aSlice, 15);
         graph.WMG_Pie_Slice_MouseEnter -= myPieSliceHoverFunction;
         WMG_Anim.animPositionCallbackC(aSlice.gameObject, 1, DG.Tweening.Ease.OutQuad, newPos, () =>
         {
             graph.WMG_Pie_Slice_MouseEnter += myPieSliceHoverFunction;
         });
     }
     else
     {
         Vector3 newPos = graph.getPositionFromExplode(aSlice, 0);
         graph.WMG_Pie_Slice_MouseEnter -= myPieSliceHoverFunction;
         WMG_Anim.animPositionCallbackC(aSlice.gameObject, 1, DG.Tweening.Ease.OutQuad, newPos, () =>
         {
             graph.WMG_Pie_Slice_MouseEnter += myPieSliceHoverFunction;
         });
     }
 }
Ejemplo n.º 3
0
 void shrinkSlices(int sliceNum)
 {
     if (!animSortSwap && sortBy != sortMethod.None)
     {
         animSortSwap = sortData();
     }
     if (animSortSwap)
     {
         if (sortAnimationDuration > 0)
         {
             WMG_Anim.animScaleCallbackC(slices[sliceNum], sortAnimationDuration / 2, Ease.Linear, Vector3.zero, () => enlargeSlices(sliceNum));
         }
         else
         {
             isAnimating = false;
             UpdateVisuals(true);
         }
     }
     else
     {
         isAnimating = false;
     }
 }
    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;
        }
    }
Ejemplo n.º 5
0
    void UpdateVisuals(bool noAnim)
    {
        // Update internal bookkeeping variables
        UpdateData();

        // Creates and deletes slices and slice legend objects based on the slice values
        CreateOrDeleteSlicesBasedOnValues();

        // Update background
        changeSpriteHeight(background, Mathf.RoundToInt(pieSize + topBotPadding.x + topBotPadding.y));
        changeSpriteWidth(background, Mathf.RoundToInt(pieSize + leftRightPadding.x + leftRightPadding.y));
        changeSpriteSize(backgroundCircle, Mathf.RoundToInt(pieSize + bgCircleOffset), Mathf.RoundToInt(pieSize + bgCircleOffset));
        Vector2 offset = getPaddingOffset();

        changeSpritePositionTo(slicesParent, new Vector3(-offset.x, -offset.y));

        if (animationDuration == 0 && sortBy != sortMethod.None)
        {
            sortData();
        }
        float curTotalRot = 0;

        if (!noAnim)
        {
            animSortSwap = false;                  // Needed because if sortAnimationDuration = 0, nothing sets animSortSwap to false
        }
        for (int i = 0; i < numSlices; i++)
        {
            WMG_Legend_Entry entry = legend.legendEntries[i];
            // Update Pie Slices
            float newAngle = -1 * curTotalRot;
            if (newAngle < 0)
            {
                newAngle += 360;
            }
            WMG_Pie_Graph_Slice pieSlice = slices[i].GetComponent <WMG_Pie_Graph_Slice>();
            if (sliceLabelType != WMG_Enums.labelTypes.None && !activeInHierarchy(pieSlice.objectToLabel))
            {
                SetActive(pieSlice.objectToLabel, true);
            }
            if (sliceLabelType == WMG_Enums.labelTypes.None && activeInHierarchy(pieSlice.objectToLabel))
            {
                SetActive(pieSlice.objectToLabel, false);
            }

            if (!explodeSymmetrical)
            {
                changeSpriteSize(pieSlice.objectToColor, Mathf.RoundToInt(pieSize), Mathf.RoundToInt(pieSize));
            }
            else
            {
                int newSize = Mathf.RoundToInt(pieSize + explodeLength * 2);
                changeSpriteSize(pieSlice.objectToColor, newSize, newSize);
                changeSpriteSize(pieSlice.objectToMask, newSize + Mathf.RoundToInt(explodeLength * 4), newSize + Mathf.RoundToInt(explodeLength * 4));
            }

            // Set Slice Data and maybe Other Slice Data
            Color  sliceColor = sliceColors[i];
            string sliceLabel = sliceLabels[i];
            float  sliceValue = sliceValues[i];
            if (isOtherSlice && i == numSlices - 1)
            {
                sliceColor = includeOthersColor;
                sliceLabel = includeOthersLabel;
                sliceValue = otherSliceValue;
            }

            // Hide if 0
            if (sliceValue == 0)
            {
                SetActive(pieSlice.objectToLabel, false);
            }

            float slicePercent      = sliceValue / totalVal;
            float afterExplodeAngle = newAngle * -1 + 0.5f * slicePercent * 360;
            float sliceLabelRadius  = sliceLabelExplodeLength + pieSize / 2;
            float sin = Mathf.Sin(afterExplodeAngle * Mathf.Deg2Rad);
            float cos = Mathf.Cos(afterExplodeAngle * Mathf.Deg2Rad);

            if (!noAnim && animationDuration > 0)
            {
                isAnimating = true;
                WMG_Anim.animFill(pieSlice.objectToColor, animationDuration, Ease.Linear, slicePercent);
                WMG_Anim.animPosition(pieSlice.objectToLabel, animationDuration, Ease.Linear, new Vector3(sliceLabelRadius * sin,
                                                                                                          sliceLabelRadius * cos));
                int newI = i;
                WMG_Anim.animPositionCallbackC(slices[i], animationDuration, Ease.Linear, new Vector3(explodeLength * sin,
                                                                                                      explodeLength * cos), () => shrinkSlices(newI));
                if (!explodeSymmetrical)
                {
                    WMG_Anim.animRotation(pieSlice.objectToColor, animationDuration, Ease.Linear, new Vector3(0, 0, newAngle), false);
                    WMG_Anim.animPosition(pieSlice.objectToColor, animationDuration, Ease.Linear, Vector3.zero);
                }
                else
                {
                    WMG_Anim.animRotation(pieSlice.objectToColor, animationDuration, Ease.Linear, Vector3.zero, false);
                    Vector2 newPos = new Vector2(-explodeLength * sin, -explodeLength * cos);
                    float   sin2   = Mathf.Sin(newAngle * Mathf.Deg2Rad);
                    float   cos2   = Mathf.Cos(newAngle * Mathf.Deg2Rad);
                    WMG_Anim.animPosition(pieSlice.objectToColor, animationDuration, Ease.Linear, new Vector3(cos2 * newPos.x + sin2 * newPos.y, cos2 * newPos.y - sin2 * newPos.x));
                    // Mask
                    WMG_Anim.animRotation(pieSlice.objectToMask, animationDuration, Ease.Linear, new Vector3(0, 0, newAngle), false);
                    WMG_Anim.animFill(pieSlice.objectToMask, animationDuration, Ease.Linear, slicePercent);
                }
            }
            else
            {
                changeSpriteFill(pieSlice.objectToColor, slicePercent);
                pieSlice.objectToLabel.transform.localPosition = new Vector3(sliceLabelRadius * sin,
                                                                             sliceLabelRadius * cos);
                slices[i].transform.localPosition = new Vector3(explodeLength * sin,
                                                                explodeLength * cos);
                if (!explodeSymmetrical)
                {
                    pieSlice.objectToColor.transform.localEulerAngles = new Vector3(0, 0, newAngle);
                    pieSlice.objectToColor.transform.localPosition    = Vector3.zero;
                }
                else
                {
                    pieSlice.objectToColor.transform.localEulerAngles = Vector3.zero;
                    Vector2 newPos = new Vector2(-explodeLength * sin, -explodeLength * cos);
                    float   sin2   = Mathf.Sin(newAngle * Mathf.Deg2Rad);
                    float   cos2   = Mathf.Cos(newAngle * Mathf.Deg2Rad);
                    pieSlice.objectToColor.transform.localPosition = new Vector3(cos2 * newPos.x + sin2 * newPos.y, cos2 * newPos.y - sin2 * newPos.x);
                    // Mask
                    pieSlice.objectToMask.transform.localEulerAngles = new Vector3(0, 0, newAngle);
                    changeSpriteFill(pieSlice.objectToMask, slicePercent);
                }
            }

            // Update slice color
            changeSpriteColor(pieSlice.objectToColor, sliceColor);
            changeSpriteColor(pieSlice.objectToMask, sliceColor);

            // Update slice labels
            changeLabelText(pieSlice.objectToLabel, getLabelText(sliceLabel, sliceLabelType, sliceValue, slicePercent, numberDecimalsInPercents));
            pieSlice.objectToLabel.transform.localScale = new Vector3(sliceLabelFontSize, sliceLabelFontSize);

            // Update Gameobject names
            slices[i].name = sliceLabel;
            legend.legendEntries[i].name = sliceLabel;

            // Update legend
            changeLabelText(entry.label, getLabelText(sliceLabel, legend.labelType, sliceValue, slicePercent, legend.numDecimals));
            changeSpriteColor(entry.swatchNode, sliceColor);

            // Hide legend if 0
            if (sliceValue == 0)
            {
                SetActive(entry.gameObject, false);
            }
            else
            {
                SetActive(entry.gameObject, true);
            }

            curTotalRot += slicePercent * 360;
        }
    }
Ejemplo n.º 6
0
    void UpdateVisuals(bool noAnim)
    {
        // Update internal bookkeeping variables
        UpdateData();

        // Creates and deletes slices and slice legend objects based on the slice values
        CreateOrDeleteSlicesBasedOnValues();

        if (totalVal == 0 && numSlices > 0)
        {
            return;                                         // all values are 0, or mixed negative and positive values
        }
        // Update explode symmetrical
        for (int i = 0; i < numSlices; i++)
        {
            WMG_Pie_Graph_Slice pieSlice = slices[i].GetComponent <WMG_Pie_Graph_Slice>();
            SetActive(pieSlice.objectToMask, explodeSymmetrical);
            if (explodeSymmetrical)
            {
                changeSpriteParent(pieSlice.objectToColor, pieSlice.objectToMask);
            }
            else
            {
                changeSpriteParent(pieSlice.objectToColor, pieSlice.gameObject);
                bringSpriteToFront(pieSlice.objectToLabel);
            }
        }

        int thePieSize = Mathf.RoundToInt(pieSize);

        updateBG(thePieSize);

        if (animationDuration == 0 && sortBy != sortMethod.None)
        {
            sortData();
        }
        float curTotalRot = 0;

        if (!noAnim)
        {
            animSortSwap = false;                  // Needed because if sortAnimationDuration = 0, nothing sets animSortSwap to false
        }
        for (int i = 0; i < numSlices; i++)
        {
            // Update Pie Slices
            float newAngle = -1 * curTotalRot;
            if (newAngle < 0)
            {
                newAngle += 360;
            }
            WMG_Pie_Graph_Slice pieSlice = slices[i].GetComponent <WMG_Pie_Graph_Slice>();
            if (sliceLabelType != WMG_Enums.labelTypes.None && !activeInHierarchy(pieSlice.objectToLabel))
            {
                SetActive(pieSlice.objectToLabel, true);
            }
            if (sliceLabelType == WMG_Enums.labelTypes.None && activeInHierarchy(pieSlice.objectToLabel))
            {
                SetActive(pieSlice.objectToLabel, false);
            }

            if (!explodeSymmetrical)
            {
                changeSpriteSize(pieSlice.objectToColor, thePieSize, thePieSize);
            }
            else
            {
                changeSpriteSize(pieSlice.objectToColor, thePieSize, thePieSize);
                changeSpriteSize(pieSlice.objectToMask,
                                 thePieSize + Mathf.RoundToInt(explodeLength * 4),
                                 thePieSize + Mathf.RoundToInt(explodeLength * 4));
            }

            // Set Slice Data and maybe Other Slice Data
            Color  sliceColor = sliceColors[i];
            string sliceLabel = sliceLabels[i];
            float  sliceValue = sliceValues[i];
            if (isOtherSlice && i == numSlices - 1)
            {
                sliceColor = includeOthersColor;
                sliceLabel = includeOthersLabel;
                sliceValue = otherSliceValue;
            }
            if (!LabelToSliceMap.ContainsKey(sliceLabel))
            {
                LabelToSliceMap.Add(sliceLabel, pieSlice);
            }

            // Hide if 0
            if (sliceValue == 0)
            {
                SetActive(pieSlice.objectToLabel, false);
            }

            float slicePercent = sliceValue / totalVal;
            pieSlice.slicePercent = slicePercent * 360;
            float afterExplodeAngle = newAngle * -1 + 0.5f * slicePercent * 360;
            float sliceLabelRadius  = sliceLabelExplodeLength + thePieSize / 2;
            float sin = Mathf.Sin(afterExplodeAngle * Mathf.Deg2Rad);
            float cos = Mathf.Cos(afterExplodeAngle * Mathf.Deg2Rad);

            if (!noAnim && animationDuration > 0)
            {
                isAnimating = true;
                WMG_Anim.animFill(pieSlice.objectToColor, animationDuration, Ease.Linear, slicePercent);
                WMG_Anim.animPosition(pieSlice.objectToLabel, animationDuration, Ease.Linear, new Vector3(sliceLabelRadius * sin,
                                                                                                          sliceLabelRadius * cos));
                int newI = i;
                WMG_Anim.animPositionCallbackC(slices[i], animationDuration, Ease.Linear, new Vector3(explodeLength * sin,
                                                                                                      explodeLength * cos), () => shrinkSlices(newI));
                if (!explodeSymmetrical)
                {
                    WMG_Anim.animRotation(pieSlice.objectToColor, animationDuration, Ease.Linear, new Vector3(0, 0, newAngle), false);
                    WMG_Anim.animPosition(pieSlice.objectToColor, animationDuration, Ease.Linear, Vector3.zero);
                }
                else
                {
                    WMG_Anim.animRotation(pieSlice.objectToColor, animationDuration, Ease.Linear, Vector3.zero, false);
                    Vector2 newPos = new Vector2(-explodeLength * sin, -explodeLength * cos);
                    float   sin2   = Mathf.Sin(newAngle * Mathf.Deg2Rad);
                    float   cos2   = Mathf.Cos(newAngle * Mathf.Deg2Rad);
                    WMG_Anim.animPosition(pieSlice.objectToColor, animationDuration, Ease.Linear, new Vector3(cos2 * newPos.x + sin2 * newPos.y, cos2 * newPos.y - sin2 * newPos.x));
                    // Mask
                    WMG_Anim.animRotation(pieSlice.objectToMask, animationDuration, Ease.Linear, new Vector3(0, 0, newAngle), false);
                    WMG_Anim.animFill(pieSlice.objectToMask, animationDuration, Ease.Linear, slicePercent);
                }
            }
            else
            {
                changeSpriteFill(pieSlice.objectToColor, slicePercent);
                pieSlice.objectToLabel.transform.localPosition = new Vector3(sliceLabelRadius * sin,
                                                                             sliceLabelRadius * cos);
                slices[i].transform.localPosition = new Vector3(explodeLength * sin,
                                                                explodeLength * cos);
                if (!explodeSymmetrical)
                {
                    pieSlice.objectToColor.transform.localEulerAngles = new Vector3(0, 0, newAngle);
                    pieSlice.objectToColor.transform.localPosition    = Vector3.zero;
                }
                else
                {
                    pieSlice.objectToColor.transform.localEulerAngles = Vector3.zero;
                    Vector2 newPos = new Vector2(-explodeLength * sin, -explodeLength * cos);
                    float   sin2   = Mathf.Sin(newAngle * Mathf.Deg2Rad);
                    float   cos2   = Mathf.Cos(newAngle * Mathf.Deg2Rad);
                    pieSlice.objectToColor.transform.localPosition = new Vector3(cos2 * newPos.x + sin2 * newPos.y, cos2 * newPos.y - sin2 * newPos.x);
                    // Mask
                    pieSlice.objectToMask.transform.localEulerAngles = new Vector3(0, 0, newAngle);
                    changeSpriteFill(pieSlice.objectToMask, slicePercent);
                }
            }

            // Update slice color
            changeSpriteColor(pieSlice.objectToColor, sliceColor);
            changeSpriteColor(pieSlice.objectToMask, sliceColor);

            // Update slice labels
            changeLabelText(pieSlice.objectToLabel, getLabelText(sliceLabel, sliceLabelType, sliceValue, slicePercent, numberDecimalsInPercents));
            changeLabelFontSize(pieSlice.objectToLabel, sliceLabelFontSize);
            changeSpriteColor(pieSlice.objectToLabel, sliceLabelColor);

            // Update Gameobject names
            slices[i].name = sliceLabel;
            legend.legendEntries[i].name = sliceLabel;

            curTotalRot += slicePercent * 360;

            pieSlice.slicePercentPosition = curTotalRot - pieSlice.slicePercent / 2;

            // Update legend
            WMG_Legend_Entry entry = legend.legendEntries[i];
            changeLabelText(entry.label, getLabelText(sliceLabel, legend.labelType, sliceValue, slicePercent, legend.numDecimals));
            changeSpriteColor(entry.swatchNode, sliceColor);
            // Hide legend if 0
            if (hideZeroValueLegendEntry)
            {
                if (sliceValue == 0)
                {
                    SetActive(entry.gameObject, false);
                }
                else
                {
                    SetActive(entry.gameObject, true);
                }
            }
            else
            {
                SetActive(entry.gameObject, true);
            }
        }
        legend.LegendChanged();

        updateAutoCenter();

        if (!setOrig)
        {
            setOrig = true;
            setOriginalPropertyValues();
        }
    }
Ejemplo n.º 7
0
    void updateDegreesAring(int i)
    {
        Vector3 baseRotation = new Vector3(0, 0, -degrees / 2);
        float   newFill      = (360 - degrees) / 360f;

        // extra ring
        changeRadialSpriteRotation(extraRing, baseRotation);
        changeSpriteFill(extraRing, newFill);


        bool ringIsZero = false;

        WMG_Ring ring = rings[i];

        // rings
        changeRadialSpriteRotation(rings[i].ring, baseRotation);
        changeSpriteFill(rings[i].ring, newFill);
        // bands
        float valPercent = values[i] / (maxValue - minValue);

        changeRadialSpriteRotation(rings[i].band, baseRotation);
        changeSpriteFill(rings[i].band, 0);
        if (animateData)
        {
            WMG_Anim.animFill(rings[i].band, animDuration, animEaseType, newFill * valPercent);
        }
        else
        {
            changeSpriteFill(rings[i].band, newFill * valPercent);
        }
        if (valPercent == 0)
        {
            ringIsZero = true;
        }
        // labels
        int numOverlapping = 0;

        for (int j = i - 1; j >= 0; j--)
        {
            float valPercentPrev = values[j] / (maxValue - minValue);
            if (Mathf.Abs(valPercent - valPercentPrev) < 0.01f)                // within 1%
            {
                numOverlapping++;
                valPercent = valPercentPrev;
            }
        }

        Vector3 labelRotation = new Vector3(0, 0, -valPercent * (360 - degrees));

        if (animateData)
        {
            if (DOTween.IsTweening(rings[i].label.transform))               // if already animating, then don't animate relative to current rotation
            {
                updateLabelRotationAndPosition(ring, 0, numOverlapping, false);
                float degOffset = 90;
                if (ring.label.transform.localEulerAngles.z < 180)
                {
                    degOffset *= -1;
                }
                WMG_Anim.animRotation(rings[i].label, animDuration, animEaseType, labelRotation + new Vector3(0, 0, 360) + baseRotation, false);
                WMG_Anim.animRotationCallbacks(rings[i].textLine, animDuration, animEaseType, -labelRotation - baseRotation + new Vector3(0, 0, degOffset), false, () => labelRotationUpdated(ring, degOffset, numOverlapping), () => labelRotationComplete(ring, degOffset, numOverlapping));
            }
            else
            {
                rings[i].label.transform.localEulerAngles    = baseRotation;
                rings[i].textLine.transform.localEulerAngles = -baseRotation + new Vector3(0, 0, 90);
                WMG_Anim.animRotation(rings[i].label, animDuration, animEaseType, labelRotation, true);
                WMG_Anim.animRotationCallbacks(rings[i].textLine, animDuration, animEaseType, -labelRotation, true, () => labelRotationUpdated(ring, 0, numOverlapping), () => labelRotationComplete(ring, 0, numOverlapping));
            }
        }
        else
        {
            updateLabelLineBasedOnOverlap(ring, numOverlapping);
            rings[i].label.transform.localEulerAngles    = labelRotation + baseRotation;
            rings[i].textLine.transform.localEulerAngles = -labelRotation - baseRotation + new Vector3(0, 0, 90);
            updateLabelRotationAndPosition(ring, 0, numOverlapping, false);
        }

        // zero line
        zeroLine.transform.localEulerAngles     = baseRotation;
        zeroLineText.transform.localEulerAngles = -baseRotation;
        if (i == 0)
        {
            SetActive(zeroLine, !ringIsZero);
        }
        else
        {
            if (zeroLine.activeSelf)               // previously not 0
            {
                SetActive(zeroLine, !ringIsZero);
            }
            else                 // there was a zero at one point in the past, always hide
            {
                SetActive(zeroLine, false);
            }
        }
    }
Ejemplo n.º 8
0
    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));
            }
        }
    }
Ejemplo n.º 9
0
 void SliceClickEvent(WMG_Pie_Graph pieGraph, WMG_Pie_Graph_Slice aSlice)
 {
     Debug.Log("== : " + aSlice.name);
     WMG_Anim.animScale(aSlice.gameObject, 0.5f, Ease.Linear, Vector3.one * 0.8f, 0);
 }
Ejemplo n.º 10
0
        public override void Awake()
        {
            base.Awake();
            pie.Init();
            pie.interactivityEnabled = true;
            //pie.useDoughnut = true;
            pie.doughnutPercentage        = 0.5f;
            pie.explodeLength             = 0;
            pie.WMG_Pie_Slice_MouseEnter += (pieGraph, aSlice, hover) =>
            {
                //Debug.Log("Pie Slice Hover: " + pieGraph.sliceLabels[aSlice.sliceIndex]);
                if (hover)
                {
                    Vector3 newPos = pie.getPositionFromExplode(aSlice, 30);
                    WMG_Anim.animPosition(aSlice.gameObject, 1, Ease.OutQuad, newPos);
                }
                else
                {
                    Vector3 newPos = pie.getPositionFromExplode(aSlice, 0);
                    WMG_Anim.animPosition(aSlice.gameObject, 1, DG.Tweening.Ease.OutQuad, newPos);
                }
            };
            lookPie.onClick.AddListener(() =>
            {
                pie.gameObject.SetActive(true);
                bar.gameObject.SetActive(false);
                switch (dropdown.value)
                {
                case 0:
                    {
                        Department[] arr = Kernel.Current.Sql.LoadEntitys <Department>();
                        pie.sliceLabels.SetList(arr.Select(x => x.Name));
                        float[] farr = new float[arr.Length];
                        for (int i = 0; i < arr.Length; i++)
                        {
                            var l   = Kernel.Current.Sql.QueryWhere <Personnel>($"DepartmentID={arr[i].ID}").Length;
                            farr[i] = l;
                        }
                        Color[] colors = new Color[farr.Length];
                        for (int i = 0; i < colors.Length; i++)
                        {
                            colors[i] = new Color(Random.value, farr[i], Random.value);
                        }
                        pie.sliceColors.SetList(colors);
                        pie.sliceValues.SetList(farr);
                    }
                    break;

                case 1:
                    {
                        Title[] arr = Kernel.Current.Sql.LoadEntitys <Title>();
                        pie.sliceLabels.SetList(arr.Select(x => x.Name));
                        float[] farr = new float[arr.Length];
                        for (int i = 0; i < arr.Length; i++)
                        {
                            var l   = Kernel.Current.Sql.QueryWhere <Personnel>($"TitleID={arr[i].ID}").Length;
                            farr[i] = l;
                        }
                        Color[] colors = new Color[farr.Length];
                        for (int i = 0; i < colors.Length; i++)
                        {
                            colors[i] = new Color(Random.value, farr[i], Random.value);
                        }
                        pie.sliceColors.SetList(colors);
                        pie.sliceValues.SetList(farr);
                    }
                    break;

                case 2:
                    {
                        Position[] arr = Kernel.Current.Sql.LoadEntitys <Position>();
                        pie.sliceLabels.SetList(arr.Select(x => x.Name));
                        float[] farr = new float[arr.Length];
                        for (int i = 0; i < arr.Length; i++)
                        {
                            var l   = Kernel.Current.Sql.QueryWhere <Personnel>($"PositionID={arr[i].ID}").Length;
                            farr[i] = l;
                        }
                        Color[] colors = new Color[farr.Length];
                        for (int i = 0; i < colors.Length; i++)
                        {
                            colors[i] = new Color(Random.value, farr[i], Random.value);
                        }
                        pie.sliceColors.SetList(colors);
                        pie.sliceValues.SetList(farr);
                    }
                    break;

                default:
                    break;
                }
            });
            lookAxis.onClick.AddListener(() =>
            {
                pie.gameObject.SetActive(false);
                bar.gameObject.SetActive(true);
                switch (dropdown.value)
                {
                case 0:
                    {
                        Department[] arr = Kernel.Current.Sql.LoadEntitys <Department>();
                        float[] farr     = new float[arr.Length];
                        float count      = 0;
                        for (int i = 0; i < arr.Length; i++)
                        {
                            var l   = Kernel.Current.Sql.QueryWhere <Personnel>($"DepartmentID={arr[i].ID}").Length;
                            farr[i] = l;
                            count  += l;
                        }
                        bar.SetValues(arr.Select(x => x.Name).Zip(farr, (x, y) =>
                        {
                            return(new KeyValuePair <string, float>(x, y));
                        }).ToList(), count);
                    }
                    break;

                case 1:
                    {
                        Title[] arr  = Kernel.Current.Sql.LoadEntitys <Title>();
                        float[] farr = new float[arr.Length];
                        float count  = 0;
                        for (int i = 0; i < arr.Length; i++)
                        {
                            var l   = Kernel.Current.Sql.QueryWhere <Personnel>($"DepartmentID={arr[i].ID}").Length;
                            farr[i] = l;
                            count  += l;
                        }
                        bar.SetValues(arr.Select(x => x.Name).Zip(farr, (x, y) =>
                        {
                            return(new KeyValuePair <string, float>(x, y));
                        }).ToList(), count);
                    }
                    break;

                case 2:
                    {
                        Position[] arr = Kernel.Current.Sql.LoadEntitys <Position>();
                        float[] farr   = new float[arr.Length];
                        float count    = 0;
                        for (int i = 0; i < arr.Length; i++)
                        {
                            var wherelen = Kernel.Current.Sql.QueryWhere <Personnel>($"PositionID={arr[i].ID}").Length;
                            farr[i]      = wherelen;
                            count       += wherelen;
                        }
                        bar.SetValues(arr.Select(x => x.Name).Zip(farr, (x, y) =>
                        {
                            return(new KeyValuePair <string, float>(x, y));
                        }).ToList(), count);
                    }
                    break;

                default:
                    break;
                }
            });
        }