Exemplo n.º 1
0
    private void TooltipLegendLinkMouseEnter(WMG_Series aSeries, WMG_Link aLink, bool state)
    {
        if (isTooltipObjectNull()) return;
        if (!aSeries.hidePoints) return;
        if (state) {
            // Set the text
            changeLabelText(theGraph.toolTipLabel, aSeries.seriesName);

            // Resize this control to match the size of the contents
            changeSpriteWidth(theGraph.toolTipPanel, Mathf.RoundToInt(getSpriteWidth(theGraph.toolTipLabel)) + 24);

            // Ensure tooltip is in position before showing it so it doesn't appear to jump
            repositionTooltip();

            // Display the base panel
            showControl(theGraph.toolTipPanel);
            bringSpriteToFront(theGraph.toolTipPanel);

            performTooltipAnimation(aLink.transform, new Vector3(2,1.05f,1));
        }
        else {
            hideControl(theGraph.toolTipPanel);
            sendSpriteToBack(theGraph.toolTipPanel);

            performTooltipAnimation(aLink.transform, new Vector3(1,1,1));
        }
    }
Exemplo n.º 2
0
    // Use this for initialization
    void Awake()
    {
        //series1 = lineGraph1.lineSeries[0].GetComponent<WMG_Series>();
        //series12 = lineGraph1.lineSeries[1].GetComponent<WMG_Series>();
        series2 = lineGraph2.lineSeries[0].GetComponent<WMG_Series>();
        //series3 = lineGraph3.lineSeries[0].GetComponent<WMG_Series>();
        //series32 = lineGraph3.lineSeries[1].GetComponent<WMG_Series>();

        //series1.pointValues = new List<Vector2>();
        //series12.pointValues = new List<Vector2>();
        series2.pointValues = new List<Vector2>();
        //series3.pointValues = new List<Vector2>();
        //series32.pointValues = new List<Vector2>();

        //lineGraph1.yAxisMaxValue = 15;
        //lineGraph1.yAxisMinValue = 0;

        lineGraph2.yAxisMaxValue = 3;
        lineGraph2.yAxisMinValue = -3;

        //lineGraph3.yAxisMaxValue = 5;
        //lineGraph3.yAxisMinValue = -5;

        lineGraph2.axesType = WMG_Axis_Graph.axesTypes.I_IV;
        //lineGraph3.axesType = WMG_Axis_Graph.axesTypes.I_IV;

        accLog = new List <Vector2>();
        //velXLog = new List <Vector2>();
        //velYLog = new List<Vector2>();
        compactAccLog = new List<Vector2>();
        //userAccXLog = new List<Vector2>();
        //userAccYLog = new List<Vector2>();

        valuesPerPoint = accLogMemory / numberOfPoints;
    }
 private void animateLinkCallbackEnd(WMG_Series aSeries)
 {
     for (int i = 0; i < aSeries.getLines().Count; i++) {
         WMG_Link theLine = aSeries.getLines()[i].GetComponent<WMG_Link>();
         theLine.Reposition();
     }
 }
 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));
            }
        }
    }
Exemplo n.º 6
0
	// Use this for initialization
	void Start () {
		changeObjs.Add(plottingDataC);

		GameObject graphGO = GameObject.Instantiate(emptyGraphPrefab) as GameObject;
		graphGO.transform.SetParent(this.transform, false);
		graph = graphGO.GetComponent<WMG_Axis_Graph>();
		graph.legend.hideLegend = true;
		graph.stretchToParent(graphGO);
		graphOverlay = new GameObject();
		graphOverlay.AddComponent<RectTransform>();
		graphOverlay.name = "Graph Overlay";
		graphOverlay.transform.SetParent(graphGO.transform, false);
		indicatorGO = GameObject.Instantiate(indicatorPrefab) as GameObject;
		indicatorGO.transform.SetParent(graphOverlay.transform, false);
		indicatorGO.SetActive(false);
		graph.GraphBackgroundChanged += UpdateIndicatorSize;
		graph.paddingLeftRight = new Vector2(65, 60);
		graph.paddingTopBottom = new Vector2(40, 40);
		graph.xAxis.LabelType = WMG_Axis.labelTypes.ticks;
		graph.xAxis.SetLabelsUsingMaxMin = true;
		graph.autoAnimationsEnabled = false;
		graph.xAxis.hideLabels = true;
		graph.xAxis.hideTicks = true;
		graph.xAxis.hideGrid = true;
		graph.yAxis.AxisNumTicks = 5;
		graph.yAxis.hideTicks = true;
		graph.axisWidth = 1;
		graph.yAxis.MaxAutoGrow = true; // auto increase yAxis max if a point value exceeds max
		graph.yAxis.MinAutoGrow = true; // auto decrease yAxis min if a point value exceeds min
		series1 = graph.addSeries();
		series1.pointColor = Color.red;
		series1.lineColor = Color.green;
		series1.lineScale = 0.5f;
		series1.pointWidthHeight = 8;
		graph.changeSpriteColor(graph.graphBackground, Color.black);
		if (useAreaShading) {
			series1.areaShadingType = WMG_Series.areaShadingTypes.Gradient;
			series1.areaShadingAxisValue = graph.yAxis.AxisMinValue;
			series1.areaShadingColor = new Color(80f/255f, 100f/255f, 60f/255f, 1f);
		}
		graph.tooltipDisplaySeriesName = false;

		// define our own custom functions for labeling
		graph.theTooltip.tooltipLabeler = customTooltipLabeler; // override the default labeler for the tooltip
		graph.yAxis.axisLabelLabeler = customYAxisLabelLabeler; // override the default labeler for the yAxis
		series1.seriesDataLabeler = customSeriesDataLabeler; // override the default labeler for data labels (appear over points when data labels on the series are enabled)

		plottingDataC.OnChange += PlottingDataChanged;
		if (plotOnStart) {
			plottingData = true;
		}
	}
Exemplo n.º 7
0
 // This is only used stacked bar graphs
 public void UpdateTotalValues()
 {
     if (pointValuesChanged)
     {
         // Find max number points
         int maxNumValues = 0;
         for (int j = 0; j < theGraph.lineSeries.Count; j++)
         {
             if (!theGraph.activeInHierarchy(theGraph.lineSeries[j]))
             {
                 continue;
             }
             WMG_Series theSeries = theGraph.lineSeries[j].GetComponent <WMG_Series>();
             if (maxNumValues < theSeries.pointValues.Count)
             {
                 maxNumValues = theSeries.pointValues.Count;
             }
         }
         // Update total values
         for (int i = 0; i < maxNumValues; i++)
         {
             if (theGraph.TotalPointValues.Count <= i)
             {
                 theGraph.TotalPointValues.Add(0);
             }
             theGraph.TotalPointValues[i] = 0;
             for (int j = 0; j < theGraph.lineSeries.Count; j++)
             {
                 if (!theGraph.activeInHierarchy(theGraph.lineSeries[j]))
                 {
                     continue;
                 }
                 WMG_Series theSeries = theGraph.lineSeries[j].GetComponent <WMG_Series>();
                 if (theSeries.pointValues.Count > i)
                 {
                     if (theGraph.orientationType == WMG_Axis_Graph.orientationTypes.vertical)
                     {
                         theGraph.TotalPointValues[i] += (theSeries.pointValues[i].y - theGraph.yAxisMinValue);
                     }
                     else
                     {
                         theGraph.TotalPointValues[i] += (theSeries.pointValues[i].y - theGraph.xAxisMinValue);
                     }
                 }
             }
         }
     }
 }
Exemplo n.º 8
0
    /// <summary>
    /// Creates a legend entry, used in axis graphs.
    /// </summary>
    /// <returns>The legend entry.</returns>
    /// <param name="prefab">Prefab.</param>
    /// <param name="series">Series.</param>
    /// <param name="index">Index.</param>
    public WMG_Legend_Entry createLegendEntry(Object prefab, WMG_Series series, int index)
    {
        GameObject obj = Instantiate(prefab) as GameObject;

        // 3/25일 clone 복제 안하게 되면서 아래 주석처리함 -> 4/5 다시 복구
        theGraph.changeSpriteParent(obj, entriesParent);

        WMG_Legend_Entry entry = obj.GetComponent <WMG_Legend_Entry>();

        entry.seriesRef = series;
        entry.legend    = this;
        entry.nodeLeft  = theGraph.CreateNode(emptyPrefab, obj);
        entry.nodeRight = theGraph.CreateNode(emptyPrefab, obj);
        legendEntries.Insert(index, entry);
        return(entry);
    }
Exemplo n.º 9
0
    public void Init(int ch, string channelName, WMG_Axis_Graph graph)
    {
        channel = ch;
        TextChannelName.text  = channel + ". " + channelName;
        TextChannelName.color = Colours[ch - 1];

        for (int i = 0; i < 24; i++)
        {
            Transform tb = Instantiate(PrefabTimeBlock);
            tb.SetParent(TimeBlockParent, false);
        }

        graphSeries            = graph.addSeries();
        graphSeries.seriesName = channelName;
        graphSeries.lineColor  = Colours[ch - 1];
    }
    private void onAutoAnimUpdate(WMG_Series aSeries)
    {
        int            aSeriesAfterPositionsCount = aSeries.AfterPositions.Count;
        List <Vector2> newPositions = new List <Vector2>(aSeriesAfterPositionsCount);
        List <int>     newWidths    = new List <int>(aSeriesAfterPositionsCount);
        List <int>     newHeights   = new List <int>(aSeriesAfterPositionsCount);

        for (int i = 0; i < aSeriesAfterPositionsCount; 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(-1, newPositions, newWidths, newHeights);
    }
Exemplo n.º 11
0
 void TooltipNodeMouseEnter(WMG_Series aSeries, WMG_Node aNode, bool state)
 {
     if (isTooltipObjectNull() || !aSeries.seriesTooltipEnabled)
     {
         return;
     }
     if (state)
     {
         MouseEnterCommon(tooltipLabeler(aSeries, aNode), aNode.gameObject);
     }
     else
     {
         MouseExitCommon();
     }
     aSeries.tooltipPointAnimator(aSeries, aNode, state);
 }
Exemplo n.º 12
0
    public void set(GameObject graphGO, Vector3 position)
    {
        groups = new List <string>();
        data   = new List <Vector2>();
        graphGO.transform.SetParent(Graphs.transform, false);
        graphGO.transform.localScale = graphGO.transform.localScale * 1.2f;
        graphGO.transform.Translate(Vector3.up * 0.3f, Space.World);

        BackGround1 = GameObject.Find("Sprite_Black");         // 검은색
        BackGround1.transform.position += new Vector3(-0.3f, 0.7f, 0);

        graph   = graphGO.GetComponent <WMG_Axis_Graph>();
        series1 = graph.addSeries();
        graph.xAxis.AxisMaxValue = 5;

        if (useData2)
        {
            for (int i = 0; i < series1Data2.Count; i++)
            {
                string[] row = series1Data2[i].Split(',');
                groups.Add(row[0]);
                if (!string.IsNullOrEmpty(row[1]))
                {
                    float y = float.Parse(row[1]);
                    data.Add(new Vector2(i + 1, y));
                }
            }

            graph.groups.SetList(groups);
            graph.useGroups = true;

            graph.xAxis.LabelType    = WMG_Axis.labelTypes.groups;
            graph.xAxis.AxisNumTicks = groups.Count;

            series1.seriesName             = "Range Data";
            series1.UseXDistBetweenToSpace = true;
            series1.pointColor             = HexToColor("57CFEF");
            series1.lineColor = HexToColor("FFFFFF");
            series1.pointValues.SetList(data);
        }
        else
        {
            series1.pointValues.SetList(series1Data);
        }
        // graphGO.SetActive(false);
        graphGO.transform.position = position;
    }
Exemplo n.º 13
0
    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;
        }
    }
Exemplo n.º 14
0
    void Start()
    {
        GameObject graphGO = GameObject.Instantiate(emptyGraph);

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

        series1 = graph.addSeries();
        graph.xAxis.AxisMaxValue = 5;
        //graph.xAxis.AxisNumTicks = 10;


        if (useData2)
        {
            List <string>  groups = new List <string>();
            List <Vector2> data   = new List <Vector2>();
            for (int i = 0; i < series1Data2.Count; i++)
            {
                string[] row = series1Data2[i].Split(',');
                Debug.Log(row[0]);
                groups.Add(row[0]);
                if (!string.IsNullOrEmpty(row[1]))
                {
                    float y = float.Parse(row[1]);
                    data.Add(new Vector2(i + 1, y));
                }
            }

            graph.groups.SetList(groups);
            graph.useGroups = true;

            graph.xAxis.LabelType    = WMG_Axis.labelTypes.groups;
            graph.xAxis.AxisNumTicks = groups.Count;

            series1.seriesName = "Fruit Data";

            series1.UseXDistBetweenToSpace = true;
            series1.AutoUpdateXDistBetween = true;

            series1.pointValues.SetList(data);
        }
        else
        {
            series1.pointValues.SetList(series1Data);
        }
    }
Exemplo n.º 15
0
 void updateDataSeries()
 {
     if (dataSeriesChanged || graphChanged)
     {
         for (int i = 0; i < numDataSeries; i++)
         {
             if (dataSeries.Count <= i)
             {
                 WMG_Series aSeries = theGraph.addSeriesAt(numGrids + i);
                 aSeries.connectFirstToLast = true;
                 aSeries.hidePoints         = true;
                 dataSeries.Add(aSeries);
             }
             if (dataSeriesColors.Count <= i)
             {
                 dataSeriesColors.Add(new Color(Random.Range(0f, 1f), Random.Range(0f, 1f), Random.Range(0f, 1f), 1));
             }
         }
         for (int i = dataSeries.Count - 1; i >= 0; i--)
         {
             if (dataSeries[i] != null && i >= numDataSeries)
             {
                 theGraph.deleteSeriesAt(numGrids + i);
                 dataSeries.RemoveAt(i);
             }
         }
         for (int i = dataSeriesColors.Count - 1; i >= 0; i--)
         {
             if (i >= numDataSeries)
             {
                 dataSeriesColors.RemoveAt(i);
             }
         }
         for (int i = 0; i < numDataSeries; i++)
         {
             WMG_Series aSeries = theGraph.lineSeries[i + numGrids].GetComponent <WMG_Series>();
             if (randomData)
             {
                 aSeries.pointValues = theGraph.GenRadar(theGraph.GenRandomList(numPoints, radarMinVal, radarMaxVal), offset.x, offset.y, degreeOffset);
             }
             aSeries.lineScale   = dataSeriesLineWidth;
             aSeries.linePadding = dataSeriesLineWidth;
             aSeries.lineColor   = dataSeriesColors[i];
         }
     }
 }
    void Hello()
    {
        todayGeneEnergy      = transform.Find("todayGeneEnergy").GetComponent <Text>();
        nowPower             = transform.Find("nowPower").GetComponent <Text>();
        todayEqualHour       = transform.Find("todayEqualHour").GetComponent <Text>();
        todayGenePowerProfit = transform.Find("todayGenePowerProfit").GetComponent <Text>();
        barGraph             = GameObject.Find("BarGraphChe").GetComponent <WMG_Axis_Graph>();
        //删除自带的两个series
        barGraph.deleteSeries();
        barGraph.deleteSeries();

        series1 = barGraph.addSeries();  //自己添加series
        //设置为柱形图
        barGraph.graphType = WMG_Axis_Graph.graphTypes.bar_side;
        barGraph.Refresh();

        //y轴设置
        // barGraph.yAxis.AxisMaxValue = 100;
        barGraph.yAxis.AxisMinValue   = 0;
        barGraph.yAxis.AxisNumTicks   = 11;
        barGraph.yAxis.AxisLabelColor = new Color32(250, 238, 36, 255);

        //x轴设置
        barGraph.xAxis.LabelType      = WMG_Axis.labelTypes.ticks;
        barGraph.xAxis.AxisLabelColor = new Color32(250, 238, 36, 255);
        barGraph.xAxis.AxisNumTicks   = 19; //4点到22点



        series1.comboType               = WMG_Series.comboTypes.bar;
        series1.dataLabelsEnabled       = true;
        series1.dataLabelsNumDecimals   = 0;
        series1.dataLabelsFontSize      = 12;
        series1.dataLabelsColor         = new Color32(250, 238, 36, 255);
        series1.dataLabelsOffset        = new Vector2(0, 5);
        series1.UseXDistBetweenToSpace  = true;
        series1.ManuallySetXDistBetween = true;
        series1.xDistBetweenPoints      = 26f;
        series1.ManuallySetExtraXSpace  = true;
        series1.seriesName              = "光伏车棚";
        series1.extraXSpace             = 0;

        //自动更新数字到x轴中
        series1.UseXDistBetweenToSpace = true;
        barGraph.Refresh();
    }
Exemplo n.º 17
0
 void TooltipLegendNodeMouseEnter(WMG_Series aSeries, WMG_Node aNode, bool state)
 {
     if (isTooltipObjectNull())
     {
         return;
     }
     if (state)
     {
         MouseEnterCommon(aSeries.seriesName, aNode.gameObject);
         performTooltipAnimation(aNode.transform, new Vector3(2, 2, 1), theGraph.tooltipAnimationsDuration, 0, theGraph.tooltipAnimationsEasetype);
     }
     else
     {
         MouseExitCommon();
         performTooltipAnimation(aNode.transform, Vector3.one, theGraph.tooltipAnimationsDuration, 0, theGraph.tooltipAnimationsEasetype);
     }
 }
Exemplo n.º 18
0
    void Start()
    {
        //graphGO = GameObject.Instantiate(emptyGraphPrefab);
        //graphGO.transform.SetParent(this.transform, false);
        //graphGO.SetActive(graph_enabled);

        graph              = graphGO.GetComponent <WMG_Axis_Graph>();
        series1            = graph.addSeries();
        series2            = graph.addSeries();
        series2.pointColor = new Color(0, 230, 0);
        series2.lineColor  = new Color(0, 230, 0);

        series2.enabled = rec_enabled;

        graph.xAxis.AxisMinValue    = 20;
        graph.xAxis.AxisMaxValue    = 0;
        graph.autoUpdateOrigin      = false;
        graph.theOrigin             = new Vector2(0f, 0f);
        graph.xAxis.AxisTitleString = "Time";
        graph.xAxis.hideLabels      = true;
        graph.autoShrinkAtPercent   = 0f;
        graph.autoAnimationsEnabled = false;

        coroutine_time = 0.15f;//otherScript.coroutine_wait;

        otherScript  = CubeObject.GetComponent <ChangeColor>();
        rec_behavior = RecElectrode.GetComponent <ElectrodeBehavior>();

        data       = new List <Vector2>();
        data2      = new List <Vector2>();
        dataStore  = new List <Vector2>();
        data2Store = new List <Vector2>();

        cur_pos = graphGO.GetComponent <Transform>().localPosition;

        //series1.enabled = graph_enabled;
        //graphGO.SetActive(graph_enabled);
        //ToggleGraph();

        StartCoroutine(DisableGraph());

        //series1.pointValues
        //graph.xAxis.AxisMaxValue = x;
    }
Exemplo n.º 19
0
    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;
        }
    }
Exemplo n.º 20
0
    private void TooltipNodeMouseEnter(WMG_Series aSeries, WMG_Node aNode, bool state)
    {
        if (isTooltipObjectNull())
        {
            return;
        }
        if (state)
        {
            // Set tooltip text
            changeLabelText(theGraph.toolTipLabel, tooltipLabeler(aSeries, aNode));

            // Resize this control to match the size of the contents
            changeSpriteWidth(theGraph.toolTipPanel, Mathf.RoundToInt(getSpriteWidth(theGraph.toolTipLabel)) + 24);

            // Ensure tooltip is in position before showing it so it doesn't appear to jump
            repositionTooltip();

            // Display the base panel
            showControl(theGraph.toolTipPanel);
            bringSpriteToFront(theGraph.toolTipPanel);

            Vector3 newVec = new Vector3(2, 2, 1);
            if (!aSeries.seriesIsLine)
            {
                if (theGraph.orientationType == WMG_Axis_Graph.orientationTypes.vertical)
                {
                    newVec = new Vector3(1, 1.1f, 1);
                }
                else
                {
                    newVec = new Vector3(1.1f, 1, 1);
                }
            }

            performTooltipAnimation(aNode.transform, newVec);
        }
        else
        {
            hideControl(theGraph.toolTipPanel);
            sendSpriteToBack(theGraph.toolTipPanel);

            performTooltipAnimation(aNode.transform, new Vector3(1, 1, 1));
        }
    }
 public void subscribeToEvents(bool val)
 {
     for (int j = 0; j < theGraph.lineSeries.Count; j++)
     {
         if (!theGraph.activeInHierarchy(theGraph.lineSeries[j]))
         {
             continue;
         }
         WMG_Series aSeries = theGraph.lineSeries[j].GetComponent <WMG_Series>();
         if (val)
         {
             aSeries.SeriesDataChanged += SeriesDataChangedMethod;
         }
         else
         {
             aSeries.SeriesDataChanged -= SeriesDataChangedMethod;
         }
     }
 }
Exemplo n.º 22
0
 private void TooltipLegendLinkMouseEnter(WMG_Series aSeries, WMG_Link aLink, bool state)
 {
     if (isTooltipObjectNull())
     {
         return;
     }
     if (!aSeries.hidePoints)
     {
         return;
     }
     if (state)
     {
         MouseEnterCommon(aSeries.seriesName, aLink.gameObject, new Vector3(2, 1.05f, 1));
     }
     else
     {
         MouseExitCommon(aLink.gameObject);
     }
 }
    // 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));
    }
Exemplo n.º 24
0
    // Used for other graphs
    public WMG_Legend_Entry createLegendEntry(Object prefab, WMG_Series series, int index)
    {
        GameObject obj = Instantiate(prefab) as GameObject;

        theGraph.changeSpriteParent(obj, entriesParent);
        WMG_Legend_Entry entry = obj.GetComponent <WMG_Legend_Entry>();

        entry.seriesRef = series;
        entry.legend    = this;
        entry.nodeLeft  = theGraph.CreateNode(emptyPrefab, obj);
        entry.nodeRight = theGraph.CreateNode(emptyPrefab, obj);
        if (theGraph.isDaikon())
        {
            theGraph.changeSpritePivot(entry.nodeLeft, WMG_Graph_Manager.WMGpivotTypes.Center);
            theGraph.changeSpritePivot(entry.nodeRight, WMG_Graph_Manager.WMGpivotTypes.Center);
        }
        legendEntrySpacing = theGraph.getSpritePositionX(entry.label);
        legendEntries.Insert(index, entry);
        return(entry);
    }
//	IEnumerator test(GameObject go) {
//		GlobalVariableBackground.Instance.conManager.WriteLog("curX2: " + go.transform.localPosition.x + " curY2: " + go.transform.localPosition.y);
//		yield return new WaitForEndOfFrame();
//		GlobalVariableBackground.Instance.conManager.WriteLog("curX3: " + go.transform.localPosition.x + " curY3: " + go.transform.localPosition.y);
//	}

    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();
        }
        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();
        }
    }
Exemplo n.º 26
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;
    }
Exemplo n.º 27
0
 void TooltipLegendLinkMouseEnter(WMG_Series aSeries, WMG_Link aLink, bool state)
 {
     if (isTooltipObjectNull())
     {
         return;
     }
     if (!aSeries.hidePoints)
     {
         return;
     }
     if (state)
     {
         MouseEnterCommon(aSeries.seriesName, aLink.gameObject);
         performTooltipAnimation(aLink.transform, new Vector3(2, 1.05f, 1), theGraph.tooltipAnimationsDuration, 0, theGraph.tooltipAnimationsEasetype);
     }
     else
     {
         MouseExitCommon();
         performTooltipAnimation(aLink.transform, Vector3.one, theGraph.tooltipAnimationsDuration, 0, theGraph.tooltipAnimationsEasetype);
     }
 }
Exemplo n.º 28
0
    private string defaultTooltipLabeler(WMG_Series aSeries, WMG_Node aNode)
    {
        // Find out the point value data for this node
        Vector2 nodeData = aSeries.getNodeValue(aNode);
        float numberToMult = Mathf.Pow(10f, aSeries.theGraph.tooltipNumberDecimals);
        string nodeX = (Mathf.Round(nodeData.x*numberToMult)/numberToMult).ToString();
        string nodeY = (Mathf.Round(nodeData.y*numberToMult)/numberToMult).ToString();

        // Determine the tooltip text to display
        string textToSet;
        if (aSeries.seriesIsLine) {
            textToSet = "(" + nodeX + ", " + nodeY + ")";
        }
        else {
            textToSet = nodeY;
        }
        if (aSeries.theGraph.tooltipDisplaySeriesName) {
            textToSet = aSeries.seriesName + ": " + textToSet;
        }
        return textToSet;
    }
Exemplo n.º 29
0
    void Start()
    {
        changeObjs.Add(plottingDataC);

        GameObject graphGO = GameObject.Instantiate(emptyGraphPrefab) as GameObject;

        graphGO.transform.SetParent(this.transform, false);
        graph = graphGO.GetComponent <WMG_Axis_Graph>();
        //graph.stretchToParent(graphGO); // 화면에 맞게 늘리기

        graphOverlay = new GameObject();
        graphOverlay.AddComponent <RectTransform>();
        graphOverlay.name = "Graph Overlay";
        graphOverlay.transform.SetParent(graphGO.transform, false);

        graph.autoAnimationsEnabled = false;
        graph.yAxis.MaxAutoGrow     = true; // auto increase yAxis max if a point value exceeds max
        graph.yAxis.MinAutoGrow     = true; // auto decrease yAxis min if a point value exceeds min

        //graph.xAxis.AxisNumTicks = 5;
        Debug.Log("graph.xAxis.AxisMaxValue : " + graph.xAxis.AxisMaxValue);
        Debug.Log("graph.xAxis.AxisLinePadding : " + graph.xAxis.AxisLinePadding);
        Debug.Log("graph.xAxis.AxisNumTicks : " + graph.xAxis.AxisNumTicks); //

        series1 = graph.addSeries();
        //AddData();
        //if (series1Data2.Count > 0)
        //    series1.pointValues.SetList(data);

        Debug.Log("series1.UseXDistBetweenToSpace : " + series1.UseXDistBetweenToSpace);
        Debug.Log("series1.AutoUpdateXDistBetween : " + series1.AutoUpdateXDistBetween);

        //increment = 1f / 10f;// graph.xAxis.AxisMaxValue;

        plottingDataC.OnChange += PlottingDataChanged;
        if (plotOnStart)
        {
            plottingData = true;
        }
    }
Exemplo n.º 30
0
    // Awake instead of Start to ensure that initialization is done before Remote function calls are made
    void Awake()
    {
        series1 = lineGraph1.lineSeries[0].GetComponent<WMG_Series>();
        series12 = lineGraph1.lineSeries[1].GetComponent<WMG_Series>();
        series2 = lineGraph2.lineSeries[0].GetComponent<WMG_Series>();
        series3 = lineGraph3.lineSeries[0].GetComponent<WMG_Series>();
        series32 = lineGraph3.lineSeries[1].GetComponent<WMG_Series>();
        series4 = lineGraph4.lineSeries[0].GetComponent<WMG_Series>();
        series42 = lineGraph4.lineSeries[1].GetComponent<WMG_Series>();

        series1.pointValues = new List<Vector2>();
        series12.pointValues = new List<Vector2>();
        series2.pointValues = new List<Vector2> ();
        series3.pointValues = new List<Vector2>();
        series32.pointValues = new List<Vector2>();
        series4.pointValues = new List<Vector2> ();
        series42.pointValues = new List<Vector2> ();

        lineGraph1.yAxisMaxValue = 15;
        lineGraph1.yAxisMinValue = -15;
        lineGraph2.yAxisMaxValue = 15;
        lineGraph2.yAxisMinValue = -15;
        lineGraph3.yAxisMaxValue = 5;
        lineGraph3.yAxisMinValue = -5;
        lineGraph4.yAxisMaxValue = 15;
        lineGraph4.yAxisMinValue = -15;

        lineGraph1.axesType = WMG_Axis_Graph.axesTypes.I_IV;
        lineGraph2.axesType = WMG_Axis_Graph.axesTypes.I_IV;
        lineGraph3.axesType = WMG_Axis_Graph.axesTypes.I_IV;
        lineGraph4.axesType = WMG_Axis_Graph.axesTypes.I_IV;

        velXLog = new List <Vector2>();
        velYLog = new List<Vector2>();
        velLog = new List<Vector2> ();
        userAccXLog = new List<Vector2>();
        userAccYLog = new List<Vector2>();
        warpedTimeLog = new List<Vector2> ();
        realTimeLog = new List<Vector2> ();
    }
Exemplo n.º 31
0
    // Awake instead of Start to ensure that initialization is done before Remote function calls are made
    void Awake()
    {
        series1  = lineGraph1.lineSeries[0].GetComponent <WMG_Series>();
        series12 = lineGraph1.lineSeries[1].GetComponent <WMG_Series>();
        series2  = lineGraph2.lineSeries[0].GetComponent <WMG_Series>();
        series3  = lineGraph3.lineSeries[0].GetComponent <WMG_Series>();
        series32 = lineGraph3.lineSeries[1].GetComponent <WMG_Series>();
        series4  = lineGraph4.lineSeries[0].GetComponent <WMG_Series>();
        series42 = lineGraph4.lineSeries[1].GetComponent <WMG_Series>();

        series1.pointValues  = new List <Vector2>();
        series12.pointValues = new List <Vector2>();
        series2.pointValues  = new List <Vector2> ();
        series3.pointValues  = new List <Vector2>();
        series32.pointValues = new List <Vector2>();
        series4.pointValues  = new List <Vector2> ();
        series42.pointValues = new List <Vector2> ();

        lineGraph1.yAxisMaxValue = 15;
        lineGraph1.yAxisMinValue = -15;
        lineGraph2.yAxisMaxValue = 15;
        lineGraph2.yAxisMinValue = -15;
        lineGraph3.yAxisMaxValue = 5;
        lineGraph3.yAxisMinValue = -5;
        lineGraph4.yAxisMaxValue = 15;
        lineGraph4.yAxisMinValue = -15;

        lineGraph1.axesType = WMG_Axis_Graph.axesTypes.I_IV;
        lineGraph2.axesType = WMG_Axis_Graph.axesTypes.I_IV;
        lineGraph3.axesType = WMG_Axis_Graph.axesTypes.I_IV;
        lineGraph4.axesType = WMG_Axis_Graph.axesTypes.I_IV;

        velXLog       = new List <Vector2>();
        velYLog       = new List <Vector2>();
        velLog        = new List <Vector2> ();
        userAccXLog   = new List <Vector2>();
        userAccYLog   = new List <Vector2>();
        warpedTimeLog = new List <Vector2> ();
        realTimeLog   = new List <Vector2> ();
    }
Exemplo n.º 32
0
    // Use this for initialization
    void Start()
    {
        graphGO = GameObject.Instantiate(emptyGraphPrefab);
        graphGO.transform.SetParent(this.transform, false);
        graph = graphGO.GetComponent <WMG_Axis_Graph> ();


        series1 = graph.addSeries();
        series1.pointValues.SetList(series1Data);

        //graph.xAxis.AxisMaxValue = 5;

        //if (useData2) {
        //	List<string> groups = new List<string>();
        //	List<Vector2> data = new List<Vector2>();
        //	for (int i = 0; i < series1Data2.Count; i++) {
        //		string[] row = series1Data2[i].Split(',');
        //		groups.Add(row[0]);
        //		if (!string.IsNullOrEmpty(row[1])) {
        //			float y = float.Parse(row[1]);
        //			data.Add(new Vector2(i+1, y));
        //		}
        //	}

        //	graph.groups.SetList(groups);
        //	graph.useGroups = true;

        //	graph.xAxis.LabelType = WMG_Axis.labelTypes.groups;
        //	graph.xAxis.AxisNumTicks = groups.Count;

        //	series1.seriesName = "Look at a page to get started";

        //	series1.UseXDistBetweenToSpace = true;

        //	series1.pointValues.SetList(data);
        //}
        //else {
        //	series1.pointValues.SetList(series1Data);
        //}
    }
Exemplo n.º 33
0
    public void fillGraphData()
    {
        WMG_Series series = graph.lineSeries[0].GetComponent <WMG_Series>();

        series.seriesName        = "GDP"; // should come from obj
        graph.graphTitleString   = "GDP";
        series.pointColor        = Color.cyan;
        graph.yAxis.AxisMaxValue = history.Max() * 1.1f;
        graph.yAxis.AxisMinValue = history.Min() * 0.9f;
        graph.xAxis.AxisMaxValue = history.Count;
        graph.xAxis.AxisMinValue = 1;
        WMG_List <Vector2> pointValues = series.pointValues;

        pointValues.Clear();
        float x = 0;

        for (int i = 0; i < history.Count; i++)
        {
            pointValues.Add(new Vector2(x++, history.Get(i)));
        }
        graph.Refresh();
    }
Exemplo n.º 34
0
    void SetNums(List <float> data, List <float> data2)
    {
        if (data != null)
        {
            //Debug.Log("SetNums 2"+graph.lineSeries.Count+""+(0 + conf.numGrids));
            WMG_Series aSeries = graph.lineSeries[0 + conf.numGrids].GetComponent <WMG_Series>();

            aSeries.pointValues = graph.GenRadar(data, conf.offset.x, conf.offset.y, conf.degreeOffset);
        }

        if (data2 != null)
        {
            graph.lineSeries[1 + conf.numGrids].gameObject.SetActive(true);
            WMG_Series aSeries = graph.lineSeries[1 + conf.numGrids].GetComponent <WMG_Series>();

            aSeries.pointValues = graph.GenRadar(data2, conf.offset.x, conf.offset.y, conf.degreeOffset);
        }
        else
        {
            graph.lineSeries[1 + conf.numGrids].gameObject.SetActive(false);
        }
    }
Exemplo n.º 35
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);
    }
Exemplo n.º 36
0
    void Hello()
    {
        //删除自带的两个series
        barGraph.deleteSeries();
        barGraph.deleteSeries();

        //设置为柱形图
        barGraph.graphType = WMG_Axis_Graph.graphTypes.bar_side;

        //y轴设置
        barGraph.yAxis.hideGrid = true;
        //  barGraph.yAxis.AxisMaxValue = 100;   //y轴最大值,设为自动
        barGraph.yAxis.AxisMinValue   = 0;
        barGraph.yAxis.AxisNumTicks   = 11;
        barGraph.yAxis.AxisLabelColor = new Color32(250, 238, 36, 255);

        //x轴设置
        barGraph.xAxis.AxisNumTicks   = 24; //0点到23点
        barGraph.xAxis.hideGrid       = true;
        barGraph.xAxis.LabelType      = WMG_Axis.labelTypes.ticks;
        barGraph.xAxis.AxisLabelColor = new Color32(250, 238, 36, 255);



        series1                         = barGraph.addSeries(); //自己添加series
        series1.comboType               = WMG_Series.comboTypes.bar;
        series1.dataLabelsEnabled       = true;
        series1.dataLabelsNumDecimals   = 0;  //主子图形上显示几位小数
        series1.dataLabelsFontSize      = 12;
        series1.dataLabelsColor         = new Color32(250, 238, 36, 255);
        series1.dataLabelsOffset        = new Vector2(0, 5);
        series1.UseXDistBetweenToSpace  = true;
        series1.ManuallySetXDistBetween = true;
        series1.xDistBetweenPoints      = 21.9f; //调整间距
        series1.ManuallySetExtraXSpace  = true;
        series1.extraXSpace             = 0;
        series1.seriesName              = "配电系统";
        barGraph.Refresh();
    }
Exemplo n.º 37
0
    void Hello()
    {
        amountOfchargeText = transform.Find("amountOfchargeText").GetComponent <Text>();
        costOfChargeText   = transform.Find("costOfChargeText").GetComponent <Text>();
        lineGraph          = GameObject.Find("LineGraphTest").GetComponent <WMG_Axis_Graph>();

        lineGraph.graphType = WMG_Axis_Graph.graphTypes.bar_side;   //设置为柱形图

        //删除自带的两个series
        lineGraph.deleteSeries();
        lineGraph.deleteSeries();

        //y轴设置
        // lineGraph.yAxis.AxisMaxValue = 15;
        lineGraph.yAxis.AxisNumTicks = 11;
        lineGraph.yAxis.AxisMinValue = 0;
        lineGraph.yAxis.hideTicks    = false;

        //x轴设置
        lineGraph.xAxis.AxisNumTicks   = 24;//0~23
        lineGraph.xAxis.LabelType      = WMG_Axis.labelTypes.ticks;
        lineGraph.xAxis.AxisLabelColor = new Color32(250, 238, 36, 255);
        lineGraph.xAxis.hideTicks      = false;


        series1 = lineGraph.addSeries();        //自己添加series
        series1.dataLabelsEnabled       = true; //柱形图头顶数字显示
        series1.dataLabelsNumDecimals   = 0;
        series1.dataLabelsFontSize      = 12;
        series1.dataLabelsColor         = new Color32(250, 238, 36, 255); //头顶数字颜色
        series1.seriesName              = "充电桩";
        series1.UseXDistBetweenToSpace  = true;
        series1.ManuallySetXDistBetween = true;
        series1.xDistBetweenPoints      = 21.7f;
        series1.ManuallySetExtraXSpace  = true;
        series1.extraXSpace             = 0;
        lineGraph.Refresh();
    }
Exemplo n.º 38
0
    // Use this for initialization
    void Start()
    {
        GameObject graphGO = GameObject.Instantiate(emptyGraphPrefab);
        graphGO.transform.SetParent(this.transform, false);
        graph = graphGO.GetComponent<WMG_Axis_Graph>();

        series1 = graph.addSeries();
        graph.xAxis.AxisMaxValue = 5;

        if (useData2) {
            List<string> groups = new List<string>();
            List<Vector2> data = new List<Vector2>();
            for (int i = 0; i < series1Data2.Count; i++) {
                string[] row = series1Data2[i].Split(',');
                groups.Add(row[0]);
                if (!string.IsNullOrEmpty(row[1])) {
                    float y = float.Parse(row[1]);
                    data.Add(new Vector2(i+1, y));
                }
            }

            graph.groups.SetList(groups);
            graph.useGroups = true;

            graph.xAxis.LabelType = WMG_Axis.labelTypes.groups;
            graph.xAxis.AxisNumTicks = groups.Count;

            series1.seriesName = "Fruit Data";

            series1.UseXDistBetweenToSpace = true;
            series1.AutoUpdateXDistBetween = true;

            series1.pointValues.SetList(data);
        }
        else {
            series1.pointValues.SetList(series1Data);
        }
    }
Exemplo n.º 39
0
    public override void SetData()
    {
        costGraph.Init();
        costS1 = costGraph.lineSeries[0].GetComponent <WMG_Series>();

        List <Vector2> list1 = new List <Vector2>();

        for (int i = 0; i < costFixedQualityList.Count; i++)
        {
            list1.Add(new Vector2(i + 1, costFixedQualityList[i]));
        }
        costS1.pointValues.SetList(list1);

        List <Vector2> list2 = new List <Vector2>();

        for (int i = 0; i < costNonFixedQualityList.Count; i++)
        {
            list2.Add(new Vector2(i + 1, costNonFixedQualityList[i]));
        }
        costS2.pointValues.SetList(list2);

        costGraph.xAxis.axisLabels.SetList(costMonthList);
    }
Exemplo n.º 40
0
	string customSeriesDataLabeler(WMG_Series series, float val) {
		seriesDataLabelsNumberFormatInfo.CurrencyDecimalDigits = series.dataLabelsNumDecimals;
		return val.ToString("C", seriesDataLabelsNumberFormatInfo);
	}
Exemplo n.º 41
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 (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;
        }
    }
Exemplo n.º 42
0
 public void addSeriesForAutoAnim(WMG_Series aSeries)
 {
     aSeries.SeriesDataChanged += SeriesDataChangedMethod;
 }
Exemplo n.º 43
0
 void OnEnable()
 {
     series = (WMG_Series)target;
     fields = GetProperties(series);
 }
Exemplo n.º 44
0
 private void animateLinkCallbackEnd(WMG_Series aSeries)
 {
     aSeries.RepositionLines();
     aSeries.currentlyAnimating = false;
 }
Exemplo n.º 45
0
 // Used for other graphs
 public WMG_Legend_Entry createLegendEntry(Object prefab, WMG_Series series, int index)
 {
     GameObject obj = Instantiate(prefab) as GameObject;
     theGraph.changeSpriteParent(obj, entriesParent);
     WMG_Legend_Entry entry = obj.GetComponent<WMG_Legend_Entry>();
     entry.seriesRef = series;
     entry.legend = this;
     entry.nodeLeft = theGraph.CreateNode(emptyPrefab, obj);
     entry.nodeRight = theGraph.CreateNode(emptyPrefab, obj);
     if (theGraph.isDaikon()) {
         theGraph.changeSpritePivot(entry.nodeLeft, WMG_Graph_Manager.WMGpivotTypes.Center);
         theGraph.changeSpritePivot(entry.nodeRight, WMG_Graph_Manager.WMGpivotTypes.Center);
     }
     legendEntrySpacing = theGraph.getSpritePositionX(entry.label);
     legendEntries.Insert(index, entry);
     return entry;
 }
Exemplo n.º 46
0
	private void TooltipNodeMouseEnter(WMG_Series aSeries, WMG_Node aNode, bool state) {
		if (isTooltipObjectNull()) return;
		if (state) {
			// Set tooltip text
			changeLabelText(theGraph.toolTipLabel, tooltipLabeler(aSeries, aNode));
			
			// Resize this control to match the size of the contents
			changeSpriteWidth(theGraph.toolTipPanel, Mathf.RoundToInt(getSpriteWidth(theGraph.toolTipLabel)) + 24);
			
			// Ensure tooltip is in position before showing it so it doesn't appear to jump
			repositionTooltip();
			
			// Display the base panel
			showControl(theGraph.toolTipPanel);
			bringSpriteToFront(theGraph.toolTipPanel);
			
			Vector3 newVec = new Vector3(2,2,1);
			if (!aSeries.seriesIsLine) {
				if (theGraph.orientationType == WMG_Axis_Graph.orientationTypes.vertical) {
					newVec = new Vector3(1,1.1f,1);
				}
				else {
					newVec = new Vector3(1.1f,1,1);
				}
			}
			
			performTooltipAnimation(aNode.transform, newVec);
		}
		else {
			hideControl(theGraph.toolTipPanel);
			sendSpriteToBack(theGraph.toolTipPanel);
			
			performTooltipAnimation(aNode.transform, new Vector3(1,1,1));
		}
	}
Exemplo n.º 47
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(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;
			changeLabelFontSize(labelGOs[i], fontSize);
			changeLabelText(labelGOs[i], labelStrings[i]);
		}
		radarLabels.pointColor = labelsColor;
	}
Exemplo n.º 48
0
	string customTooltipLabeler(WMG_Series aSeries, WMG_Node aNode) {
		Vector2 nodeData = aSeries.getNodeValue(aNode);
		tooltipNumberFormatInfo.CurrencyDecimalDigits = aSeries.theGraph.tooltipNumberDecimals;
		string textToSet = nodeData.y.ToString("C", tooltipNumberFormatInfo);
		if (aSeries.theGraph.tooltipDisplaySeriesName) {
			textToSet = aSeries.seriesName + ": " + textToSet;
		}
		return textToSet;
	}
Exemplo n.º 49
0
    private void SetHistGraphSeries(List<Vector2> history)
    {
        WMG_Axis_Graph graph = historyGraph.GetComponent<WMG_Axis_Graph>();
        if (series != null)
            series.pointValues.Clear();
        else 
            series = graph.addSeries();
       
        //Set the month labels (x axis)
        SetMonthLabels(graph);

        List<Vector2> ptValues;
        if (history.Count >= 4)
        {//IF there's enough history to fill the graph, get the last 3 values
            ptValues = history.GetRange(carbHistory.Count - 3, 3);
        }
        else {//Else, just use what there is
            ptValues = history;
        }

        histGraphY = 10;
        for (int i = 0; i < ptValues.Count; i++) {
            if (histGraphY < ptValues[i].y)
                histGraphY = (int)ptValues[i].y + 100;

            ptValues[i] = new Vector2(i + 1, ptValues[i].y);
        }

        graph.yAxis.AxisMaxValue = histGraphY;
        Color ptColor = new Color(134f/255f, 115f/255f, 63f/255f);
        series.pointColor = ptColor;
        series.pointValues.SetList(ptValues);
    }
Exemplo n.º 50
0
 public string formatSeriesDataLabel(WMG_Series series, float val)
 {
     float numberToMult = Mathf.Pow(10f, series.dataLabelsNumDecimals);
     return (Mathf.Round(val * numberToMult) / numberToMult).ToString();
 }
	private void animateLinkCallbackEnd(WMG_Series aSeries, bool isLast) {
		aSeries.RepositionLines();
		if (isLast) {
			aSeries.updateAreaShading();
		}
		aSeries.currentlyAnimating = false;
	}
Exemplo n.º 52
0
    private void TooltipNodeMouseEnter(WMG_Series aSeries, WMG_Node aNode, bool state)
    {
        if (isTooltipObjectNull()) return;
        if (state) {
            // Find out what point value data is for this node
            Vector2 nodeData = aSeries.getNodeValue(aNode);
            float numberToMult = Mathf.Pow(10f, theGraph.tooltipNumberDecimals);
            string nodeX = (Mathf.Round(nodeData.x*numberToMult)/numberToMult).ToString();
            string nodeY = (Mathf.Round(nodeData.y*numberToMult)/numberToMult).ToString();

            // Determine the tooltip to display and set the text
            string textToSet;
            if (theGraph.graphType != WMG_Axis_Graph.graphTypes.line) {
                textToSet = nodeY;
            }
            else {
                textToSet = "(" + nodeX + ", " + nodeY + ")";
            }
            if (theGraph.tooltipDisplaySeriesName) {
                textToSet = aSeries.seriesName + ": " + textToSet;
            }
            changeLabelText(theGraph.toolTipLabel, textToSet);

            // Resize this control to match the size of the contents
            changeSpriteWidth(theGraph.toolTipPanel, Mathf.RoundToInt(getSpriteWidth(theGraph.toolTipLabel)) + 24);

            // Ensure tooltip is in position before showing it so it doesn't appear to jump
            repositionTooltip();

            // Display the base panel
            showControl(theGraph.toolTipPanel);
            bringSpriteToFront(theGraph.toolTipPanel);

            Vector3 newVec = new Vector3(2,2,1);
            if (theGraph.graphType != WMG_Axis_Graph.graphTypes.line) {
                if (theGraph.orientationType == WMG_Axis_Graph.orientationTypes.vertical) {
                    newVec = new Vector3(1,1.1f,1);
                }
                else {
                    newVec = new Vector3(1.1f,1,1);
                }
            }

            performTooltipAnimation(aNode.transform, newVec);
        }
        else {
            hideControl(theGraph.toolTipPanel);
            sendSpriteToBack(theGraph.toolTipPanel);

            performTooltipAnimation(aNode.transform, new Vector3(1,1,1));
        }
    }