Exemple #1
0
        protected virtual void OnSceneGUI()
        {
            SmartChart chart = (SmartChart)target;

            if (useCustomHandles)
            {
                Undo.RecordObject(chart.GetComponent <RectTransform>(), "chart rect modification");
                RectHandles.ResizeRect(chart.GetComponent <RectTransform>(), Handles.CubeHandleCap, Color.cyan, HandleUtility.GetHandleSize(Vector3.zero) * 0.35f, 1);
            }
            chart.UpdateChart();
        }
Exemple #2
0
        /// <summary>
        /// Updates charts data to contain new value at the beggining of dataset.
        /// </summary>
        /// <param name="value">Value to be pushed onto the chart.</param>
        public void PushValue(float value)
        {
            if (chart.chartData.Length != 0)
            {
                value *= valueModifier;

                chartDataList.Insert(0, new Vector2(0, value));

                for (int i = 1; i < chartDataList.Count; i++)
                {
                    chartDataList[i] = new Vector2(i * xModifier, chartDataList[i].y);
                    if (chartDataList[i].x > chart.maxXValue)
                    {
                        chartDataList.RemoveAt(i);
                    }
                }

                chart.chartData[dataIndex].data = chartDataList.ToArray();

                if (adjustYRange)
                {
                    float maxValue     = GetMaxValue();
                    float lastMaxValue = chart.maxYValue;

                    if (maxValue > minYValue)
                    {
                        chart.maxYValue = maxValue;
                    }
                    else
                    {
                        chart.maxYValue = minYValue;
                    }

                    if (lastMaxValue != chart.maxYValue)
                    {
                        chart.SetupValues(false);
                    }
                }

                chart.UpdateChart();
            }
        }
Exemple #3
0
        public override void OnInspectorGUI()
        {
            SetupStyles();
            serializedObject.Update();
            chart = (SmartChart)target;
            EditorGUI.BeginChangeCheck();

            GUILayout.BeginVertical("box");
            EditorGUI.indentLevel++;
            ChartDataSection();
            SizingOptionsSection();
            AxesOptionsSection();
            GridOptionsSection();
            LabelsOptionsSection();
            MarkersOptionsSection();
            EditorGUI.indentLevel--;
            EditorGUILayout.Space();
            GUI.backgroundColor = Color.white;
            SerializedProperty uch = serializedObject.FindProperty("useCustomHandles");

            EditorGUILayout.PropertyField(uch, new GUIContent("Use Custom Handles (experimental)"));
            useCustomHandles = uch.boolValue;
            GUILayout.EndVertical();


            if (EditorGUI.EndChangeCheck())
            {
                serializedObject.ApplyModifiedProperties();

                int dataCount = 0;
                for (int i = 0; i < chart.chartData.Length; i++)
                {
                    dataCount += chart.chartData[i].data.Length;
                }

                chart.DeleteMarkers(dataCount);
                chart.SetupValues(true);
                chart.UpdateChart();
            }
        }