Esempio n. 1
0
 void updateGrids()
 {
     for (int i = 0; i < numGrids; i++)
     {
         if (grids.Count <= i)
         {
             WMG_Series aGrid = addSeriesAt(i);
             aGrid.connectFirstToLast = true;
             aGrid.hidePoints         = true;
             grids.Add(aGrid);
         }
     }
     for (int i = grids.Count - 1; i >= 0; i--)
     {
         if (grids[i] != null && i >= numGrids)
         {
             deleteSeriesAt(i);
             grids.RemoveAt(i);
         }
     }
     for (int i = 0; i < numGrids; i++)
     {
         WMG_Series aGrid = lineSeries[i].GetComponent <WMG_Series>();
         aGrid.pointValues.SetList(WMG_Util.GenCircular(numPoints, offset.x, offset.y, (i + 1f) / numGrids * (radarMaxVal - radarMinVal), degreeOffset));
         aGrid.lineScale   = gridLineWidth;
         aGrid.linePadding = gridLineWidth;
         aGrid.lineColor   = gridColor;
     }
 }
Esempio n. 2
0
    // Use this for initialization
    void Start()
    {
        GameObject graphGO = GameObject.Instantiate(emptyGraphPrefab);

        graphGO.transform.SetParent(this.transform, false);
        graph = graphGO.GetComponent <WMG_Axis_Graph>();

        graph.stretchToParent(graphGO);

        graph.Init();
        graph.graphType = WMG_Axis_Graph.graphTypes.line_stacked;
        graph.useGroups = true;

        List <string> groups = new List <string>()
        {
            "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20"
        };

        graph.groups.SetList(groups);

        for (int i = 0; i < numSeries; i++)
        {
            WMG_Series series = graph.addSeries();
            series.lineColor              = new Color(Random.Range(0f, 1f), Random.Range(0f, 1f), Random.Range(0f, 1f), 1);
            series.pointColor             = series.lineColor;
            series.UseXDistBetweenToSpace = true;
            int numPoints = Random.Range(maxNumPoints / 2, maxNumPoints);
            series.pointValues.SetList(WMG_Util.GenRandomY(numPoints, maxNumPoints - numPoints + 1, maxNumPoints, graph.yAxis.AxisMinValue / numSeries, graph.yAxis.AxisMaxValue / numSeries));
        }
    }
    void onUpdateAnimateAddPoint(Vector2 newEnd, Vector2 oldEnd, Vector2 newStart, Vector2 oldStart)
    {
        series1.pointValues[series1.pointValues.Count - 1] = WMG_Util.RemapVec2(addPointAnimTimeline, 0, 1, oldEnd, newEnd);

        float previousAxisMax = graph.xAxis.AxisMaxValue;
        float previousAxisMin = graph.xAxis.AxisMinValue;

        graph.xAxis.AxisMaxValue = WMG_Util.RemapFloat(addPointAnimTimeline, 0, 1, oldEnd.x, newEnd.x);

        updateIndicator();

        if (moveXaxisMinimum)
        {
            series1.pointValues[0]   = WMG_Util.RemapVec2(addPointAnimTimeline, 0, 1, oldStart, newStart);
            graph.xAxis.AxisMinValue = WMG_Util.RemapFloat(addPointAnimTimeline, 0, 1, oldStart.x, newStart.x);

            if (moveVerticalGridLines)
            {
                float totalXaxisValue       = previousAxisMax - previousAxisMin;
                float axisValuePerGridLine  = totalXaxisValue / (graph.xAxis.AxisNumTicks - 1);
                float axisPixelsPerLength   = graph.xAxis.AxisLength / totalXaxisValue;
                float axisPixelsPerGridLine = axisPixelsPerLength * axisValuePerGridLine;
                float axisValueMoveAmt      = graph.xAxis.AxisMinValue - previousAxisMin;
                currentXaxisGridOffset += axisPixelsPerLength * axisValueMoveAmt;
                // reset the grid offset by the amount of space between two gridlines, otherwise would need to increase # of grid lines
                if (currentXaxisGridOffset > axisPixelsPerGridLine)
                {
                    currentXaxisGridOffset -= axisPixelsPerGridLine;
                }
                // get the first grid line and hide if position is offset, otherwise will see a a grid line outside of the graph boundaries
                graph.xAxis.GridLines.GetComponent <WMG_Grid>().getColumn(0)[0].links[0].gameObject.SetActive(currentXaxisGridOffset == 0);
                graph.changeSpritePositionToX(graph.xAxis.GridLines, -currentXaxisGridOffset);
            }
        }
    }
Esempio n. 4
0
    public void Init(WMG_Bezier_Band_Graph graph)
    {
        this.graph = graph;
//		theGraph.setTextureMaterial(areaShadingRects[i], matToUse);
        bandFillSprite = WMG_Util.createSprite(getTexture(bandFillSpriteGO));
        bandLineSprite = WMG_Util.createSprite(getTexture(bandLineSpriteGO));
//		bandFillSprite = WMG_Util.createAlphaSprite(1024);
//		bandLineSprite = WMG_Util.createAlphaSprite(1024);
//		bandBotLineSprite = WMG_Util.createSprite(getTexture(bandBotLineSpriteGO));
        texSize = bandFillSprite.texture.width;
//		texSize = 1024;
        bandFillColors = new Color[texSize * texSize];
        bandLineColors = new Color[texSize * texSize];
//		bandBotLineColors = new Color[texSize * texSize];
        setTexture(bandFillSpriteGO, bandFillSprite);
        setTexture(bandLineSpriteGO, bandLineSprite);
//		setTexture(bandBotLineSpriteGO, bandBotLineSprite);
        size = Mathf.RoundToInt(Mathf.Sqrt(bandFillColors.Length));
//		size = 1024;
        maxS = size - 1;
//		setTextureMaterial(bandFillSpriteGO, graph.uiGradient);
//		setTextureMaterial(bandLineSpriteGO, graph.uiGradient);
//		bandFillMat = getTextureMaterial(bandFillSpriteGO);
//		bandLineMat = getTextureMaterial(bandLineSpriteGO);
    }
Esempio n. 5
0
 public void valuesChanged(bool editorChange, bool countChanged, bool oneValChanged, int index)
 {
     if (countChanged)
     {
         if (editorChange)
         {
             beforeValCount.Add(values.Count);
             afterValCount.Add(_values.Count);
         }
         else
         {
             beforeValCount.Add(_values.Count);
             afterValCount.Add(values.Count);
         }
     }
     WMG_Util.listChanged(editorChange, ref values, ref _values, oneValChanged, index);
     if (countChanged)
     {
         AllChanged();
     }
     else
     {
         if (oneValChanged)
         {
             aRingValChangeIndices.Add(index);
             aRingValC.Changed();
         }
         else
         {
             degreesC.Changed();
         }
     }
 }
Esempio n. 6
0
 void Start()
 {
     extraRingSprite = WMG_Util.createSprite(getTexture(extraRing));
     ringTexSize     = extraRingSprite.texture.width;
     extraRingColors = new Color[ringTexSize * ringTexSize];
     setTexture(extraRing, extraRingSprite);
     rings = new List <WMG_Ring>();
 }
 void updateData()
 {
     for (int i = 0; i < graph.numDataSeries; i++)           // loop through each radar data series (other series are grids and labels)
     {
         WMG_Series aSeries = graph.lineSeries[i + graph.numGrids].GetComponent <WMG_Series>();
         aSeries.pointValues.SetList(WMG_Util.GenRadar(testData, graph.offset.x, graph.offset.y, graph.degreeOffset));
     }
 }
Esempio n. 8
0
 void UpdateLabels()
 {
     for (int i = 0; i < values.Count; i++)
     {
         changeLabelText(bands[i].percentLabel, WMG_Util.FormatValueLabel("", WMG_Enums.labelTypes.Percents_Only, 0, (bands[i].cumulativePercent - bands[i].prevCumulativePercent), numDecimals));
         changeLabelText(bands[i].label, labels[i]);
     }
 }
Esempio n. 9
0
    void onUpdateAnimateBandFill(int ringNum, float endFill)
    {
        float ringRadius = graph.getRingRadius(graph.pieMode ? 0 : ringNum);
        float newFill    = WMG_Util.RemapFloat(animTimeline, 0, 1, 0, endFill);

        graph.textureChanger(band, bandSprite, (2 * ringNum + 1) + 1, graph.outerRadius * 2, ringRadius + graph.bandPadding,
                             (graph.pieMode ? graph.outerRadius : (graph.getRingRadius(ringNum + 1))) - graph.ringWidth - graph.bandPadding, graph.antiAliasing, graph.antiAliasingStrength, newFill);
    }
Esempio n. 10
0
 public void initialize(WMG_Ring_Graph graph)
 {
     ringSprite = WMG_Util.createSprite(getTexture(ring));
     bandSprite = WMG_Util.createSprite(getTexture(band));
     setTexture(ring, ringSprite);
     setTexture(band, bandSprite);
     this.graph = graph;
     changeSpriteParent(label, graph.ringLabelsParent);
 }
Esempio n. 11
0
    public void Init()
    {
        if (hasInit)
        {
            return;
        }
        hasInit = true;

        changeObjs.Add(numberRingsC);
        changeObjs.Add(textureC);
        changeObjs.Add(degreesC);
        changeObjs.Add(aRingValC);
        changeObjs.Add(ringColorC);
        changeObjs.Add(bandColorC);
        changeObjs.Add(radiusC);
        changeObjs.Add(labelsC);
        changeObjs.Add(hideRingsC);

        textureChanger = defaultTextureChanger;
        colorChanger   = defaultColorChanger;

        extraRingSprite = WMG_Util.createSprite(getTexture(extraRing));
        ringTexSize     = extraRingSprite.texture.width;
        extraRingColors = new Color[ringTexSize * ringTexSize];
        setTexture(extraRing, extraRingSprite);
        rings          = new List <WMG_Ring>();
        origGraphWidth = ((1 - innerRadiusPercentage) * outerRadius);

        bandColors.SetList(_bandColors);
        bandColors.Changed += bandColorsChanged;

        values.SetList(_values);
        values.Changed += valuesChanged;

        labels.SetList(_labels);
        labels.Changed += labelsChanged;

        hideRings.SetList(_hideRings);
        hideRings.Changed += hideRingsChanged;

        ringIDs.SetList(_ringIDs);
        ringIDs.Changed += ringIDsChanged;

        numberRingsC.OnChange += NumberRingsChanged;
        bandColorC.OnChange   += BandColorChanged;
        ringColorC.OnChange   += RingColorChanged;
        labelsC.OnChange      += LabelsChanged;
        degreesC.OnChange     += DegreesChanged;
        aRingValC.OnChange    += DegreesChangedAring;
        radiusC.OnChange      += RadiusChanged;
        textureC.OnChange     += TextureChanged;
        hideRingsC.OnChange   += HideRingsChanged;

        PauseCallbacks();
    }
Esempio n. 12
0
 public void Init(WMG_Bezier_Band_Graph graph)
 {
     this.graph     = graph;
     texSize        = graph.textureResolution;
     bandFillSprite = WMG_Util.createSprite(texSize, texSize);
     bandLineSprite = WMG_Util.createSprite(texSize, texSize);
     bandFillColors = new Color[texSize * texSize];
     bandLineColors = new Color[texSize * texSize];
     setTexture(bandFillSpriteGO, bandFillSprite);
     setTexture(bandLineSpriteGO, bandLineSprite);
 }
Esempio n. 13
0
    void updateFromResize()
    {
        bool resizeChanged = false;

        WMG_Util.updateCacheAndFlag <float>(ref cachedContainerWidth, getSpriteWidth(this.gameObject), ref resizeChanged);
        WMG_Util.updateCacheAndFlag <float>(ref cachedContainerHeight, getSpriteHeight(this.gameObject), ref resizeChanged);
        if (resizeChanged)
        {
            resizeC.Changed();
        }
    }
Esempio n. 14
0
    public void Plot(float?newMinX = null, float?newMaxX = null, float?newMinY = null, float?newMaxY = null)
    {
        if (newMinX != null)
        {
            minX = (float)newMinX;
        }
        if (newMaxX != null)
        {
            maxX = (float)newMaxX * 1.02f;
        }
        if (newMinY != null)
        {
            minY = (float)newMinY;
        }
        if (newMaxY != null)
        {
            maxY = (float)newMaxY;
        }

        //Debug.Log("Range: " + minX + " to " + maxX);
        float intervalX = (maxX - minX) / pointNum;
        //Debug.Log("Best Fit Line Interval: " + intervalX);

        string yExpression = ExpressionForY(rounded: false);

        // exception for y = infinity.
        if (yExpression == "")
        {
            dataSeries.seriesName = "\ty = undefined";
            return;
        }
        // get data series legend to show r, to save space
        dataSeries.seriesName = "\tr = " + PearsonsPMCC(rounded: true);
        lineSeries.seriesName = "\ty = " + ExpressionForY(rounded: true);

        lineSeries.pointValues.Clear();

        string        formattedEquationStr = EnsureDelimiterAroundOperatorsAndParentheses(yExpression);
        List <string> rpnString            = WMG_Util.ShuntingYardAlgorithm(formattedEquationStr);

        for (float i = minX; i <= (maxX + Mathf.Epsilon); i += intervalX)
        {
            i = Mathf.Round(i * decimalsMultiplier) / decimalsMultiplier;
            Vector2 expResult = WMG_Util.ExpressionEvaluator(rpnString, i);
            if (!float.IsNaN(expResult.y) && (minY <= expResult.y) && (expResult.y <= maxY))
            {
                lineSeries.pointValues.Add(expResult);
            }
        }

        //Debug.Log("y = " + ExpressionForY(rounded:true));
    }
Esempio n. 15
0
 public void initialize(WMG_Ring_Graph graph)
 {
     ringSprite  = WMG_Util.createSprite(getTexture(ring));
     bandSprite  = WMG_Util.createSprite(getTexture(band));
     ringTexSize = ringSprite.texture.width;
     bandTexSize = bandSprite.texture.width;
     ringColors  = new Color[ringTexSize * ringTexSize];
     bandColors  = new Color[bandTexSize * bandTexSize];
     setTexture(ring, ringSprite);
     setTexture(band, bandSprite);
     this.graph = graph;
     changeSpriteParent(label, graph.ringLabelsParent);
 }
Esempio n. 16
0
 public void initialize(WMG_Ring_Graph graph)
 {
     this.graph = graph;
     texSize    = graph.textureResolution;
     ringSprite = WMG_Util.createSprite(texSize, texSize);
     bandSprite = WMG_Util.createSprite(texSize, texSize);
     setTexture(ring, ringSprite);
     setTexture(band, bandSprite);
     changeSpriteParent(label, graph.ringLabelsParent);
     graph.addRingClickEvent(interactibleObj);
     graph.addRingMouseEnterEvent(interactibleObj);
     ringIndex = graph.rings.Count;
 }
Esempio n. 17
0
    void onUpdateAnimateAddPoint(Vector2 newEnd, Vector2 oldEnd, Vector2 newStart, Vector2 oldStart)
    {
        series1.pointValues[series1.pointValues.Count - 1] = WMG_Util.RemapVec2(addPointAnimTimeline, 0, 1, oldEnd, newEnd);
        graph.xAxis.AxisMaxValue = WMG_Util.RemapFloat(addPointAnimTimeline, 0, 1, oldEnd.x, newEnd.x);

        updateIndicator();

        if (moveXaxisMinimum)
        {
            series1.pointValues[0]   = WMG_Util.RemapVec2(addPointAnimTimeline, 0, 1, oldStart, newStart);
            graph.xAxis.AxisMinValue = WMG_Util.RemapFloat(addPointAnimTimeline, 0, 1, oldStart.x, newStart.x);
        }
    }
Esempio n. 18
0
 void checkCache()
 {
     WMG_Util.updateCacheAndFlag <gridTypes>(ref cachedGridType, gridType, ref gridChanged);
     WMG_Util.updateCacheAndFlag <Object>(ref cachedNodePrefab, nodePrefab, ref gridChanged);
     WMG_Util.updateCacheAndFlag <Object>(ref cachedLinkPrefab, linkPrefab, ref gridChanged);
     WMG_Util.updateCacheAndFlag <int>(ref cachedGridNumNodesX, gridNumNodesX, ref gridChanged);
     WMG_Util.updateCacheAndFlag <int>(ref cachedGridNumNodesY, gridNumNodesY, ref gridChanged);
     WMG_Util.updateCacheAndFlag <float>(ref cachedGridLinkLengthX, gridLinkLengthX, ref gridChanged);
     WMG_Util.updateCacheAndFlag <float>(ref cachedGridLinkLengthY, gridLinkLengthY, ref gridChanged);
     WMG_Util.updateCacheAndFlag <bool>(ref cachedCreateLinks, createLinks, ref gridChanged);
     WMG_Util.updateCacheAndFlag <bool>(ref cachedNoVerticalLinks, noVerticalLinks, ref gridChanged);
     WMG_Util.updateCacheAndFlag <bool>(ref cachedNoHorizontalLinks, noHorizontalLinks, ref gridChanged);
     WMG_Util.updateCacheAndFlag <Color>(ref cachedLinkColor, linkColor, ref gridChanged);
     WMG_Util.updateCacheAndFlag <int>(ref cachedLinkWidth, linkWidth, ref gridChanged);
 }
Esempio n. 19
0
    private void onAutoAnimUpdate(WMG_Series aSeries)
    {
        List <Vector2> newPositions = new List <Vector2>();
        List <int>     newWidths    = new List <int>();
        List <int>     newHeights   = new List <int>();

        for (int i = 0; i < aSeries.AfterPositions.Count; i++)
        {
            newPositions.Add(WMG_Util.RemapVec2(aSeries.autoAnimationTimeline, 0, 1, aSeries.OrigPositions[i], aSeries.AfterPositions[i]));
            newWidths.Add(Mathf.RoundToInt(WMG_Util.RemapFloat(aSeries.autoAnimationTimeline, 0, 1, aSeries.OrigWidths[i], aSeries.AfterWidths[i])));
            newHeights.Add(Mathf.RoundToInt(WMG_Util.RemapFloat(aSeries.autoAnimationTimeline, 0, 1, aSeries.OrigHeights[i], aSeries.AfterHeights[i])));
        }

        aSeries.UpdateVisuals(newPositions, newWidths, newHeights);
    }
Esempio n. 20
0
 void updateRingsAndBands()
 {
     // extra ring
     if (bandMode)
     {
         float ringRadius = getRingRadius(rings.Count);
         WMG_Util.updateBandColors(ref extraRingColors, outerRadius * 2, ringRadius - ringWidth, ringRadius, antiAliasing, antiAliasingStrength);
         extraRingSprite.texture.SetPixels(extraRingColors);
         extraRingSprite.texture.Apply();
     }
     // rings and bands
     for (int i = 0; i < rings.Count; i++)
     {
         rings[i].updateRing(i);
     }
 }
    void updateGrids()
    {
        // create or delete grids
        for (int i = 0; i < numGrids; i++)
        {
            if (grids.Count <= i)
            {
                WMG_Series aGrid = addSeriesAt(i);
                aGrid.hidePoints = true;
                grids.Add(aGrid);
            }
        }
        for (int i = grids.Count - 1; i >= 0; i--)
        {
            if (grids[i] != null && i >= numGrids)
            {
                deleteSeriesAt(i);
                grids.RemoveAt(i);
            }
        }
        // update grid data
        List <Vector2> alternateGridTypeOuterPoints = new List <Vector2>();

        if (alternateGridType)
        {
            alternateGridTypeOuterPoints = WMG_Util.GenCircular(numPoints, offset.x, offset.y, (radarMaxVal - radarMinVal), degreeOffset);
        }
        for (int i = 0; i < numGrids; i++)
        {
            WMG_Series aGrid = lineSeries[i].GetComponent <WMG_Series>();
            aGrid.connectFirstToLast = alternateGridType ? false : true;
            if (alternateGridType)
            {
                List <Vector2> gridPoints = new List <Vector2> ();
                gridPoints.Add(new Vector2(offset.x, offset.y));
                gridPoints.Add(alternateGridTypeOuterPoints [i]);
                aGrid.pointValues.SetList(gridPoints);
            }
            else
            {
                aGrid.pointValues.SetList(WMG_Util.GenCircular(numPoints, offset.x, offset.y, (i + 1f) / numGrids * (radarMaxVal - radarMinVal), degreeOffset));
            }
            aGrid.lineScale   = gridLineWidth;
            aGrid.linePadding = gridLineWidth;
            aGrid.lineColor   = gridColor;
        }
    }
    public void OnPlot()
    {
        series.seriesName = equationStr;
        series.pointValues.Clear();

        string        formattedEquationStr = ensureDelimiterAroundOperatorsAndParentheses(equationStr);
        List <string> rpnString            = WMG_Util.ShuntingYardAlgorithm(formattedEquationStr);

        for (float i = minX; i <= (maxX + Mathf.Epsilon); i += intervalX)
        {
            i = Mathf.Round(i * decimalsMultiplier) / decimalsMultiplier;
            Vector2 expResult = WMG_Util.ExpressionEvaluator(rpnString, i);
            if (!float.IsNaN(expResult.y))
            {
                series.pointValues.Add(expResult);
            }
        }
    }
    // Use this for initialization
    void Start()
    {
        GameObject graphGO = GameObject.Instantiate(emptyGraphPrefab);

        graphGO.transform.SetParent(this.transform, false);
        graph = graphGO.GetComponent <WMG_Axis_Graph>();

        graph.stretchToParent(graphGO);

        graph.xAxis.AxisMinValue         = 0;
        graph.yAxis.AxisMinValue         = 0;
        graph.xAxis.AxisMaxValue         = 100;
        graph.yAxis.AxisMaxValue         = 100;
        graph.legend.hideLegend          = true;
        graph.xAxis.SetLabelsUsingMaxMin = true;
        graph.xAxis.LabelType            = WMG_Axis.labelTypes.ticks;

        graph.autoAnimationsEnabled = true;

        series1            = graph.addSeries();
        series1.hidePoints = true;
        series1.lineScale  = 0.4f;
        if (useComputeShader)
        {
            series1.areaShadingTextureResolution = 4096;
            if (drawAreaShading)
            {
                series1.areaShadingType = WMG_Series.areaShadingTypes.Gradient;
                series1.areaShadingUsesComputeShader = true;
                series1.areaShadingColor             = Color.blue;
                series1.areaShadingAxisValue         = 0;
            }
            series1.linesUseComputeShader = true;
            series1.neverCreateLines      = true;
            series1.neverCreatePoints     = true;
        }
        else
        {
            series1.LineCreated  += groupLinesInCanvases;
            series1.PointCreated += groupPointsInCanvases;
        }
        series1.pointValues.SetList(WMG_Util.GenRandomY(numPointsToCreate, 0, 100, 0, 100));
    }
Esempio n. 24
0
 void updateDataSeries()
 {
     for (int i = 0; i < numDataSeries; i++)
     {
         if (dataSeries.Count <= i)
         {
             WMG_Series aSeries = addSeriesAt(numGrids + i);
             aSeries.connectFirstToLast = true;
             aSeries.hidePoints         = true;
             dataSeries.Add(aSeries);
         }
         if (dataSeriesColors.Count <= i)
         {
             dataSeriesColors.AddNoCb(new Color(Random.Range(0f, 1f), Random.Range(0f, 1f), Random.Range(0f, 1f), 1), ref _dataSeriesColors);
         }
     }
     for (int i = dataSeries.Count - 1; i >= 0; i--)
     {
         if (dataSeries[i] != null && i >= numDataSeries)
         {
             deleteSeriesAt(numGrids + i);
             dataSeries.RemoveAt(i);
         }
     }
     for (int i = dataSeriesColors.Count - 1; i >= 0; i--)
     {
         if (i >= numDataSeries)
         {
             dataSeriesColors.RemoveAtNoCb(i, ref _dataSeriesColors);
         }
     }
     for (int i = 0; i < numDataSeries; i++)
     {
         WMG_Series aSeries = lineSeries[i + numGrids].GetComponent <WMG_Series>();
         if (randomData)
         {
             aSeries.pointValues.SetList(WMG_Util.GenRadar(WMG_Util.GenRandomList(numPoints, radarMinVal, radarMaxVal), offset.x, offset.y, degreeOffset));
         }
         aSeries.lineScale   = dataSeriesLineWidth;
         aSeries.linePadding = dataSeriesLineWidth;
         aSeries.lineColor   = dataSeriesColors[i];
     }
 }
Esempio n. 25
0
 void Update()
 {
     if (Input.GetKeyDown(KeyCode.A))
     {
         List <Vector2> randomList = WMG_Util.GenRandomXY(200, 0, 100, 0, 100);
         for (int i = 0; i < randomList.Count; i++)
         {
             series1.pointValues[Random.Range(0, numPointsToCreate)] = randomList[i];
         }
     }
     if (Input.GetKeyDown(KeyCode.B))
     {
         List <Vector2> randomList = WMG_Util.GenRandomXY(1, 0, 100, 0, 100);
         for (int i = 0; i < randomList.Count; i++)
         {
             series1.pointValues[i] = randomList[i];
         }
     }
 }
Esempio n. 26
0
    void createTextureData()
    {
        GameObject temp = GameObject.Instantiate(nodePrefab) as GameObject;

        pieSprite = WMG_Util.createSprite(getTexture(temp.GetComponent <WMG_Pie_Graph_Slice>().objectToColor));
        Destroy(temp);
        texSize      = pieSprite.texture.width;
        colors       = new Color[texSize * texSize];
        cachedColors = pieSprite.texture.GetPixels();
        // get alphaBorderSize, used to determine maximum doughnut radius
        Color[] tempC = pieSprite.texture.GetPixels(texSize / 2, 0, 1, texSize / 2);
        for (int i = 0; i < tempC.Length; i++)
        {
            if (tempC[i].a != 0)
            {
                alphaBorderSize = i + 5;
                break;
            }
        }
    }
Esempio n. 27
0
    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;
    }
 void Update()
 {
     if (Input.GetKeyDown(KeyCode.A))
     {
         List <float> randomList = WMG_Util.GenRandomList(200, 0, 100);
         for (int i = 0; i < randomList.Count; i++)
         {
             int xIndex = Random.Range(0, numPointsToCreate);
             series1.pointValues[xIndex] = new Vector2(series1.pointValues[xIndex].x, randomList[i]);
         }
     }
     if (Input.GetKeyDown(KeyCode.B))
     {
         List <float> randomList = WMG_Util.GenRandomList(1, 0, 100);
         for (int i = 0; i < randomList.Count; i++)
         {
             int xIndex = Random.Range(0, numPointsToCreate);
             series1.pointValues[xIndex] = new Vector2(series1.pointValues[xIndex].x, randomList[i]);
         }
     }
 }
Esempio n. 29
0
    void initDoughnut()
    {
        if (doughnutHasInit)
        {
            return;
        }
        doughnutHasInit = true;
        GameObject temp    = GameObject.Instantiate(nodePrefab) as GameObject;
        Texture2D  origTex = getTexture(temp.GetComponent <WMG_Pie_Graph_Slice>().objectToColor);

        colors     = origTex.GetPixels();
        origColors = origTex.GetPixels();
        pieSprite  = WMG_Util.createSprite(origTex);
        Destroy(temp);
        for (int i = 0; i < slices.Count; i++)
        {
            WMG_Pie_Graph_Slice pieSlice = slices[i].GetComponent <WMG_Pie_Graph_Slice>();
            setTexture(pieSlice.objectToColor, pieSprite);
            setTexture(pieSlice.objectToMask, pieSprite);
        }
    }
Esempio n. 30
0
    // Use this for initialization
    void Start()
    {
        GameObject graphGO = GameObject.Instantiate(emptyGraphPrefab);

        graphGO.transform.SetParent(this.transform, false);
        graph = graphGO.GetComponent <WMG_Axis_Graph>();

        graph.stretchToParent(graphGO);

        graph.xAxis.AxisMinValue         = 0;
        graph.yAxis.AxisMinValue         = 0;
        graph.xAxis.AxisMaxValue         = 100;
        graph.yAxis.AxisMaxValue         = 100;
        graph.legend.hideLegend          = true;
        graph.xAxis.SetLabelsUsingMaxMin = true;
        graph.xAxis.LabelType            = WMG_Axis.labelTypes.ticks;

        graph.autoAnimationsEnabled = true;

        series1                  = graph.addSeries();
        series1.pointColor       = new Color(210 / 255f, 100 / 255f, 100 / 255f, 1);
        series1.PointCreated    += groupPointsInCanvases;
        series1.neverCreateLines = true;
        series1.pointValues.SetList(WMG_Util.GenRandomXY(numPointsToCreate, 0, 100, 0, 100));

        Canvas graphBgCanvas = graph.graphBackground.transform.parent.gameObject.AddComponent <Canvas>();

        graph.graphBackground.transform.parent.gameObject.AddComponent <GraphicRaycaster>();
        graphBgCanvas.overrideSorting = true;
        graphBgCanvas.sortingOrder    = 0;

        graph.toolTipPanel.SetActive(true);                                // for some reason setting canvas override sorting doesn't work for inactive gameobject, so enable and then set back to disable
        Canvas tooltipCanvas = graph.toolTipPanel.AddComponent <Canvas>(); // otherwise tooltip appears behind points which are on their own canvas of higher sorting order

        tooltipCanvas.overrideSorting = true;
        tooltipCanvas.sortingLayerID  = 0;
        tooltipCanvas.sortingOrder    = 2 + ((numPointsToCreate - 1) / numPointsPerCanvas);
        graph.toolTipPanel.SetActive(false);
    }