Beispiel #1
0
    public void RefreshGraph()
    {
        if (graph)
        {
            MakeSeriesList();
            series1.pointValues.SetList(series1Data);
            series2.pointValues.SetList(series2Data);
            series3.pointValues.SetList(series3Data);
            series4.pointValues.SetList(series4Data);
            //graph.Refresh (); //not needed, just need to reset the series data with the above line

            List <WMG_Node> myLabels = new List <WMG_Node> ();
            myLabels = graph.xAxis.GetAxisLabelNodes();

            WMG_List <string> myOtherLabels = new WMG_List <string> ();
            myOtherLabels = graph.xAxis.axisLabels;

            print("there are " + myLabels.Count + " x axis labels");
//			foreach (WMG_Node n in myLabels) {
//				print ("here is a list of labels for x axis " + n);
//			}

            for (int i = 0; i < myOtherLabels.Count; i++)
            {
                print("here is a list of labels for x axis before " + myOtherLabels [i]);
                myOtherLabels [i] = "Updated";
                print("here is a list of labels for x axis after" + myOtherLabels [i]);
            }
        }
    }
Beispiel #2
0
 public static void listChanged <T>(bool editorChange, ref WMG_List <T> w_list, ref List <T> list, bool oneValChanged, int index)
 {
     if (editorChange)
     {
         if (oneValChanged)
         {
             w_list.SetValViaEditor(index, list[index]);
         }
         else
         {
             w_list.SetListViaEditor(list);
         }
     }
     else
     {
         if (oneValChanged)
         {
             list[index] = w_list[index];
         }
         else
         {
             list = new List <T> (w_list);
         }
     }
 }
Beispiel #3
0
    // Use this for initialization
    void Start()
    {
        GameObject pieGraphObj = Instantiate <WMG_Pie_Graph>(pieGraphPrefab).gameObject;

        pieGraphObj.transform.SetParent(GameObject.Find("Canvas").transform, worldPositionStays: false);
        pieGraphObj.GetComponent <RectTransform>().sizeDelta     = pieGraphObj.transform.parent.GetComponent <RectTransform>().rect.size *0.3f; //全屏
        pieGraphObj.GetComponent <RectTransform>().localPosition = new Vector2(-604.6f, 119f);
        WMG_Pie_Graph pieGraph = pieGraphObj.GetComponent <WMG_Pie_Graph>();

        pieGraph.Init();

        //Debug.Log(pieGraph.gameObject.name);
        WMG_List <float> pieValues = new WMG_List <float>()
        {
            60f, 80f, 75f, 90f, 100f, 85f, 95f
        };
        WMG_List <string> pieLabels = new WMG_List <string>()
        {
            "One", "Two", "Three", "Four", "Five", "Six", "Seven"
        };
        WMG_List <Color> pieColor = new WMG_List <Color>()
        {
            Color.red, Color.yellow, Color.green, Color.blue, Color.cyan, Color.black
        };

        //pieGraph.resizeEnabled = true;

        ///////pieGraph.sliceValues = pieValues;  Debug.Log("草泥马有几个:" + pieGraph.sliceValues.Count);
        ////////pieGraph.sliceLabels = pieLabels;  //不能直接改变量,要用内置函数去改
        ////////pieGraph.sliceColors = pieColor;
        pieGraph.sliceValues.SetList(pieValues);
        pieGraph.sliceLabels.SetList(pieLabels);
        pieGraph.sliceColors.SetList(pieColor);

        pieGraph.sliceLabelExplodeLength = -10f;
        pieGraph.autoCenter = false;
        //pieGraph.autoCenterMinPadding = 10f;
        //pieGraph.bgCircleOffset = 80f;
        pieGraph.sortBy        = WMG_Pie_Graph.sortMethod.None;
        pieGraph.explodeLength = 1f;
        //pieGraph.explodeSymmetrical = false;
        pieGraph.sliceLabelFontSize       = 10;
        pieGraph.numberDecimalsInPercents = 1;


        pieGraph.interactivityEnabled        = true;
        pieGraph.WMG_Pie_Slice_Click        += SliceClickEvent;
        pieGraph.WMG_Pie_Legend_Entry_Click += SliceLegendEntryClickEvent;
        pieGraph.WMG_Pie_Slice_MouseEnter   += TooltipLegendLinkMouseEnter;

        //pieGraph.Refresh();
    }
Beispiel #4
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();
    }
	public void ArrayGUIoc<T>(WMG_List<T> observableCollection, string label, string name, SerializedObject serObj, EditorListOption options = EditorListOption.Default) {
		bool showListLabel = (options & EditorListOption.ListLabel) != 0;
		bool showListSize = (options & EditorListOption.ListSize) != 0;
		SerializedProperty list = serObj.FindProperty(name);
		
		if (showListLabel) {
			EditorGUILayout.PropertyField(list, new GUIContent(label));
			EditorGUI.indentLevel += 1;
		}
		if (!showListLabel || list.isExpanded) {
			int prevSize = list.arraySize;
			if (showListSize) {
				EditorGUILayout.PropertyField(list.FindPropertyRelative("Array.size"));
			}
			// The size changed notify observableCollection of this change
			if (prevSize != list.arraySize) {
				if (Application.isPlaying) {
					list.serializedObject.ApplyModifiedProperties ();
					observableCollection.SizeChangedViaEditor();
				}
			}

			for (int i = 0; i < list.arraySize; i++) {
				SerializedProperty prop = list.GetArrayElementAtIndex(i);
				if (prop.propertyType == SerializedPropertyType.String) {
					string prev = prop.stringValue;
					EditorGUILayout.PropertyField(prop);
					if (prev != prop.stringValue) {
						list.serializedObject.ApplyModifiedProperties ();
						observableCollection.ValueChangedViaEditor(i);
					}
				}
				else if (prop.propertyType == SerializedPropertyType.Float) {
					float prev = prop.floatValue;
					EditorGUILayout.PropertyField(prop);
					if (prev != prop.floatValue) {
						list.serializedObject.ApplyModifiedProperties ();
						observableCollection.ValueChangedViaEditor(i);
					}
				}
				else if (prop.propertyType == SerializedPropertyType.Color) {
					Color prev = prop.colorValue;
					EditorGUILayout.PropertyField(prop);
					if (prev != prop.colorValue) {
						list.serializedObject.ApplyModifiedProperties ();
						observableCollection.ValueChangedViaEditor(i);
					}
				}
				else if (prop.propertyType == SerializedPropertyType.Vector2) {
					Vector2 prev = prop.vector2Value;
					EditorGUILayout.PropertyField(prop);
					if (prev != prop.vector2Value) {
						list.serializedObject.ApplyModifiedProperties ();
						observableCollection.ValueChangedViaEditor(i);
					}
				}
				else if (prop.propertyType == SerializedPropertyType.ObjectReference) {
					UnityEngine.Object prev = prop.objectReferenceValue;
					EditorGUILayout.PropertyField(prop);
					if (prev != prop.objectReferenceValue) {
						list.serializedObject.ApplyModifiedProperties ();
						observableCollection.ValueChangedViaEditor(i);
					}
				}
				else if (prop.propertyType == SerializedPropertyType.Boolean) {
					bool prev = prop.boolValue;
					EditorGUILayout.PropertyField (prop);
					if (prev != prop.boolValue) {
						list.serializedObject.ApplyModifiedProperties ();
						observableCollection.ValueChangedViaEditor (i);
					}
				}
			}
		}
		if (showListLabel) {
			EditorGUI.indentLevel -= 1;
		}
	}
	// Function to display observable collection WMG_List<T> in inspector
	public void ArrayGUIoc<T>(WMG_List<T> observableCollection, string label, string name, EditorListOption options = EditorListOption.Default) {
		ArrayGUIoc(observableCollection, label, name, serializedObject, options);
	}
Beispiel #7
0
    // Use this for initialization
    void Start()
    {
        GameObject lineGraphObj = Instantiate <WMG_Axis_Graph>(lineGraphPrefab).gameObject;

        lineGraphObj.transform.SetParent(GameObject.Find("Canvas").transform, worldPositionStays: false);
        lineGraphObj.transform.localPosition = Vector3.zero;
        lineGraphObj.transform.localScale    = Vector3.one * 0.7f;
        lineGraphObj.GetComponent <RectTransform>().sizeDelta = lineGraphObj.transform.parent.GetComponent <RectTransform>().rect.size *0.3f; //全屏
        lineGraph = lineGraphObj.GetComponent <WMG_Axis_Graph>();
        lineGraph.Init();

        WMG_List <Vector2> pointPosGZ = new WMG_List <Vector2>()
        {
            new Vector2(1f, 3f), new Vector2(2f, 20f), new Vector2(3f, 4f),
            new Vector2(4f, 13f), new Vector2(5f, 1f), new Vector2(6f, 4f), new Vector2(7f, 16f), new Vector2(8f, 5f), new Vector2(9f, 11f), new Vector2(10, 4f),
            new Vector2(11, 6f), new Vector2(12, 7f)
        };
        WMG_List <Vector2> pointPosSZ = new WMG_List <Vector2> {
            new Vector2(1f, 16f), new Vector2(2f, 5f), new Vector2(3f, 11f), new Vector2(4, 4f),
            new Vector2(5, 6f), new Vector2(6, 7f), new Vector2(7f, 6), new Vector2(8f, 12f), new Vector2(9f, 7f), new Vector2(10, 15f),
            new Vector2(11, 12f), new Vector2(12, 3f)
        };
        WMG_List <string> lineGroups = new WMG_List <string>()
        {
            "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
        };

        //  WMG_List<Color> lineColor = new WMG_List<Color>() { Color.red, Color.yellow, Color.green, Color.blue, Color.cyan, Color.black };
        lineGraph.useGroups = true;
        lineGraph.groups.SetList(lineGroups);
        lineGraph.xAxis.axisLabels.SetList(lineGroups);
        //lineGraph.lineSeries = new List<GameObject>();
        lineGraph.lineSeries[0].GetComponent <WMG_Series>().pointValues = pointPosGZ;
        lineGraph.lineSeries[1].GetComponent <WMG_Series>().pointValues = pointPosSZ;
        lineGraph.lineSeries[0].GetComponent <WMG_Series>().seriesName  = "广州";
        lineGraph.lineSeries[1].GetComponent <WMG_Series>().seriesName  = "深圳";
        lineGraph.xAxis.LabelType = WMG_Axis.labelTypes.ticks;
        lineGraph.axisWidth       = 2;
        lineGraph.xAxis.hideGrid  = true;
        lineGraph.yAxis.hideGrid  = true;

        //lineGraph.graphType = WMG_Axis_Graph.graphTypes.bar_stacked;
        //lineGraph.orientationType = WMG_Axis_Graph.orientationTypes.horizontal;
        //lineGraph.resizeEnabled = true;
        //lineGraph.resizeProperties = WMG_Axis_Graph.ResizeProperties.AxesLabelOffset;
        //lineGraph.useGroups = true;
        //lineGraph.graphType = WMG_Axis_Graph.graphTypes.bar_side;
        //lineGraph.autoUpdateBarWidth = false;
        //lineGraph.autoUpdateBarAxisValue = false;
        //lineGraph.barWidth = 1f;
        //lineGraph.barAxisValue = 15f;
        //lineGraph.autoUpdateBarWidthSpacing = 0.1f;
        //lineGraph.resizeProperties = WMG_Axis_Graph.ResizeProperties.AutofitPadding;
        //lineGraph.resizeProperties = WMG_Axis_Graph.ResizeProperties.AxesLinePadding;
        //lineGraph.paddingLeftRight = new Vector2(70f, 50f);
        //lineGraph.paddingTopBottom = new Vector2(50f, 70f);
        //lineGraph.autoFitLabels = true;
        //lineGraph.autoFitPadding = 1f;
        //lineGraph.yAxis.AxisMinValue = 2f;
        //lineGraph.yAxis.AxisMaxValue = 13f;
        //lineGraph.yAxis.AxisNumTicks = 10;
        //lineGraph.yAxis.MinAutoGrow = true;
        //lineGraph.yAxis.MaxAutoGrow = true;
        //lineGraph.yAxis.MinAutoShrink = true;
        //lineGraph.yAxis.MaxAutoShrink = true;
        //lineGraph.yAxis.AxisLinePadding = 100f;
        //lineGraph.yAxis.HideAxisArrowTopRight = true;
        //lineGraph.yAxis.hideGrid = true;
        //lineGraph.yAxis.hideTick = true;  //没卵用
        //lineGraph.yAxis.hideTicks = true;
        lineGraph.yAxis.AxisTitleString = "出口";
        //lineGraph.yAxis.AxisTitleOffset = new Vector2(30f, 30f);
        //lineGraph.yAxis.AxisTitleFontSize = 30;


        lineGraph.Refresh();
    }