private void AddChartData() { LineDataSet set1 = new LineDataSet(); set1.AddEntry(new LineEntry(0, 110)); set1.AddEntry(new LineEntry(20, 50)); set1.AddEntry(new LineEntry(40, 70)); set1.AddEntry(new LineEntry(60, 130)); set1.AddEntry(new LineEntry(80, 150)); set1.LineColor = new Color32(54, 105, 126, 255); set1.FillColor = new Color32(54, 105, 126, 110); LineDataSet set2 = new LineDataSet(); set2.AddEntry(new LineEntry(0, 80)); set2.AddEntry(new LineEntry(20, 110)); set2.AddEntry(new LineEntry(40, 95)); set2.AddEntry(new LineEntry(60, 90)); set2.AddEntry(new LineEntry(80, 120)); set2.LineColor = new Color32(9, 107, 67, 255); set2.FillColor = new Color32(9, 107, 67, 110); chart.GetChartData().DataSets.Add(set1); chart.GetChartData().DataSets.Add(set2); chart.SetDirty(); }
private int DrawLine(UILineRenderer lineRenderer, LineDataSet dataSet, int dataSetIndex, int currentIndicatorPosition) { List <LineEntry> entries = dataSet.GetSortedEntries(); Color32 lineColor = dataSet.LineColor; lineRenderer.lineThickness = dataSet.LineThickness; lineRenderer.color = lineColor; lineRenderer.m_points = dataSet.UseBezier ? bezierPoints[dataSetIndex] : entriesPoints[dataSetIndex]; lineRenderer.BezierSegmentsPerCurve = BEZIER_LINE_SEGMENTS; lineRenderer.BezierMode = dataSet.UseBezier ? UILineRenderer.BezierType.Basic : UILineRenderer.BezierType.None; lineRenderer.SetAllDirty(); if (Config.ShowValueIndicators) { return(UpdateCirclesAtPosition(entriesPoints[dataSetIndex], entries.ToArray(), lineColor, currentIndicatorPosition, dataSetIndex)); } else { return(0); } }
private Vector2[] CreateLinePointsFromDataSet(LineDataSet dataSet) { if (dataSet.GetEntriesCount() < 1 /* || dataSet.PositionDelta () <= 0f */) { return(new Vector2[0]); } AxisBounds axisBounds = GetAxisBounds(); List <LineEntry> sortedEntries = dataSet.GetSortedEntries(); Vector2 chartSize = GetSize(); float positionDelta = axisBounds.XMax - axisBounds.XMin; float valueDelta = axisBounds.YMax - axisBounds.YMin; int index = 0; Vector2[] result = new Vector2[dataSet.Entries.Count]; sortedEntries.ForEach(entry => { float pointX = positionDelta > 0f?((entry.Position - axisBounds.XMin) / positionDelta) * chartSize.x : 0f; float pointY = valueDelta > 0f?((entry.Value - axisBounds.YMin) / valueDelta) * chartSize.y : 0f; result[index] = new Vector2(pointX, pointY); index++; }); return(result); }
private void DrawLineBackground(LineChartBackground lineBackground, LineDataSet dataSet, int dataSetIndex) { lineBackground.color = dataSet.FillColor; lineBackground.Texture = dataSet.FillTexture; lineBackground.AxisBounds = GetAxisBounds(); lineBackground.Points = dataSet.UseBezier ? CalculateBezierSegmentsPoints(bezierPoints[dataSetIndex]) : entriesPoints[dataSetIndex]; }
public void OnRemoveEntryClick() { LineDataSet dataSet = chart.GetChartData().DataSets[0]; if (dataSet.Entries.Count > 0) { dataSet.RemoveEntry(dataSet.Entries.Count - 1); chart.SetDirty(); } }
private void AddChartData(List <float> data) { // Create data set for entries LineDataSet set = new LineDataSet(); set.AddEntry(new LineEntry(0, 0)); if (data.Count <= 50) { } else { // Only show last 50 values for (int i = 1; i < 50; i++) { set.AddEntry(new LineEntry(i - 1, data[data.Count - i])); } } // Set Colours Color solid_richblack = new Color(16 / 255f, 22 / 255f, 29 / 255f, 1); Color solid_bluemunsell = new Color(78 / 255f, 149 / 255f, 164 / 255f, 1); Color solid_maxblue = new Color(71 / 255f, 186 / 255f, 210 / 255f, 0.9f); Color trans_maxblue = new Color(71 / 255f, 186 / 255f, 210 / 255f, 0.2f); Color solid_amber = new Color(255 / 255f, 127 / 255f, 17 / 255f, 1); Color trans_amber = new Color(255 / 255f, 127 / 255f, 17 / 255f, 0.2f); Color solid_snow = new Color(252 / 255f, 239 / 255f, 239 / 255f, 1); Color trans_snow = new Color(252 / 255f, 239 / 255f, 239 / 255f, 0.2f); Color solid_blue = new Color(0 / 255f, 110 / 255f, 166 / 255f, 1); Color trans_blue = new Color(0 / 255f, 110 / 255f, 166 / 255f, 0.2f); // Import texture graph_grad = (Texture2D)Resources.Load("Assets/Awesome Charts/Core/Examples/LineChart/Resources/gradient_background"); // Configure line set.LineColor = solid_blue; set.LineThickness = 2; set.FillColor = trans_blue; set.FillTexture = graph_grad; set.UseBezier = true; // Add data set to chart data lineChart.GetChartData().DataSets.Add(set); // Refresh chart after data change lineChart.SetDirty(); }
private void CalculateDataSetLinePoints(LineDataSet dataSet, int dataSetIndex) { entriesPoints[dataSetIndex] = CreateLinePointsFromDataSet(dataSet); if (dataSet.UseBezier && dataSet.GetEntriesCount() > 2) { bezierPoints[dataSetIndex] = BezierUtils.CreateBezierPointsFromLinePoints(entriesPoints[dataSetIndex]); } else { bezierPoints[dataSetIndex] = new Vector2[0]; } }
private void AddChartData() { // Create data set for entries LineDataSet set = new LineDataSet(); // Add entries to data set set.AddEntry(new LineEntry(0, 100)); set.AddEntry(new LineEntry(10, -150)); set.AddEntry(new LineEntry(15, 10)); set.AddEntry(new LineEntry(30, 130)); // Set Colours Color solid_richblack = new Color(16 / 255f, 22 / 255f, 29 / 255f, 1); Color solid_bluemunsell = new Color(78 / 255f, 149 / 255f, 164 / 255f, 1); Color solid_maxblue = new Color(71 / 255f, 186 / 255f, 210 / 255f, 0.9f); Color trans_maxblue = new Color(71 / 255f, 186 / 255f, 210 / 255f, 0.2f); Color solid_amber = new Color(255 / 255f, 127 / 255f, 17 / 255f, 1); Color solid_snow = new Color(252 / 255f, 239 / 255f, 239 / 255f, 1); // Import texture graph_grad = (Texture2D)Resources.Load("Assets/Awesome Charts/Core/Examples/LineChart/Resources/gradient_background"); // Configure line set.LineColor = solid_maxblue; set.LineThickness = 2; set.FillColor = trans_maxblue; set.FillTexture = graph_grad; set.UseBezier = true; // Add data set to chart data lineChart.GetChartData().DataSets.Add(set); // Refresh chart after data change lineChart.SetDirty(); }
public LineData(LineDataSet dataSet) : this() { dataSets.Add(dataSet); }