/// <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(); } }
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(); } }