//CREATE NEW LINE DATA SET FOR EACH THREAT TYPE, SET COLOR AND LINE THICKNESS AND ADD TO LINE CHART DATA SETS private void SetupChartDataSets() { dosSet = new LineDataSet { Title = "DOS", LineColor = colors[0], LineThickness = setLineThickness }; replaySet = new LineDataSet { Title = "REPLAY", LineColor = colors[1], LineThickness = setLineThickness }; mitmSet = new LineDataSet { Title = "MAN IN THE MIDDLE", LineColor = colors[2], LineThickness = setLineThickness }; stuxnetSet = new LineDataSet { Title = "STUXNET", LineColor = colors[3], LineThickness = setLineThickness }; dragonflySet = new LineDataSet { Title = "DRAGONFLY", LineColor = colors[4], LineThickness = setLineThickness }; malwareSet = new LineDataSet { Title = "MALWARE", LineColor = colors[5], LineThickness = setLineThickness }; sets.Add(dosSet); sets.Add(replaySet); sets.Add(mitmSet); sets.Add(stuxnetSet); sets.Add(dragonflySet); sets.Add(malwareSet); }
private LineDataSet CreateLineDataSet(Color mcolor, string mLabel, List <float> MotionList) { LineDataSet set = new LineDataSet(null, "Data") { AxisDependency = YAxis.AxisDependency.Left, LineWidth = 2.5f, Color = mcolor, HighlightEnabled = false, Label = mLabel }; set.SetDrawValues(false); set.SetDrawCircles(false); set.SetMode(LineDataSet.Mode.CubicBezier); set.CubicIntensity = 0.1f; if (MotionList.Count > max_OnCreateEntries) { for (int i = 0; i < max_OnCreateEntries; i++) { set.AddEntry(new Entry(i, MotionList[i])); } } else { for (int i = 0; i < MotionList.Count; i++) { set.AddEntry(new Entry(i, MotionList[i])); } } return(set); }
private void InitializeChart() { if (supportLineChart != null && supportLineChart.ChartData != null && lineChart != null) { SupportChart.OnInitializeChart(supportLineChart, lineChart); var data = supportLineChart.ChartData; var dataSetItems = new List <LineDataSet>(); foreach (var itemChild in data.IF_GetDataSet()) { var entryOriginal = itemChild.IF_GetEntry().Select(item => new MikePhil.Charting.Data.Entry(item.GetXPosition(), item.GetYPosition())); LineDataSet lineDataSet = new LineDataSet(entryOriginal.ToArray(), itemChild.IF_GetTitle()); lineDataSet.Color = itemChild.IF_GetDataColor().ToAndroid(); lineDataSet.SetMode(SupportChart.GetDrawLineMode(itemChild.IF_GetDrawMode())); lineDataSet.CircleRadius = itemChild.IF_GetCircleRadius(); lineDataSet.CircleHoleRadius = itemChild.IF_GetCircleHoleRadius(); lineDataSet.SetDrawCircles(itemChild.IF_GetDrawCircle()); lineDataSet.SetDrawValues(itemChild.IF_GetDrawValue()); var arrColor = itemChild.IF_GetCircleColors().Select(item => item.ToAndroid()); lineDataSet.SetCircleColor(itemChild.IF_GetCircleColor().ToAndroid()); dataSetItems.Add(lineDataSet); } LineData lineData = new LineData(dataSetItems.ToArray()); lineChart.Data = lineData; } }
void UpdatePowerMonitorChart() { var chart = FindViewById <LineChart>(Resource.Id.lineChart); Entry[] values = new Entry[powerHistory.values.Length]; for (int i = 0; i < values.Count(); i++) { values[i] = new Entry(i, powerHistory.values[i]); } LineDataSet set1; if (chart.Data != null && chart.Data.DataSetCount > 0) { set1 = (LineDataSet)chart.Data.GetDataSetByIndex(0); set1.Values = values; chart.Data.NotifyDataChanged(); chart.NotifyDataSetChanged(); } else { // create a dataset and give it a type set1 = new LineDataSet(values, "Power Usage"); set1.SetMode(LineDataSet.Mode.CubicBezier); set1.CubicIntensity = 0.2f; set1.SetDrawFilled(true); set1.SetDrawCircles(false); set1.LineWidth = 1.6f; //set1.CircleRadius = 4f; //set1.SetCircleColor(Color.White); set1.HighLightColor = Color.Rgb(244, 117, 117); set1.Color = Color.ParseColor("#68B9C0"); set1.FillColor = Color.ParseColor("#68B9C0"); set1.FillAlpha = 100; set1.SetDrawHorizontalHighlightIndicator(false); set1.SetDrawVerticalHighlightIndicator(false); // set1.FillFormatter = new IFillFormatter() { // public float getFillLinePosition(ILineDataSet dataSet, LineDataProvider dataProvider) // { // return chart.getAxisLeft().getAxisMinimum(); // } //}; // create a data object with the data sets LineData data = new LineData(set1); //data.setValueTypeface(tfLight); data.SetValueTextSize(12f); data.SetDrawValues(false); // set data chart.Data = data; } chart.SetViewPortOffsets(0, 0, 0, 0); chart.Invalidate(); }
/* * EXPORT FOR LINE */ public LineData ExportLineData(Widget.Charts.Models.LineChart.LineChartData bubbleChartData) { var dataSetItems = new List <LineDataSet>(); foreach (var item in bubbleChartData.DataSets) { var entryOriginal = item.IF_GetValues().Select(obj => new MikePhil.Charting.Data.Entry(obj.GetXPosition(), obj.GetYPosition())); var dataSet = new LineDataSet(entryOriginal.ToArray(), item.IF_GetLabel()); OnIntializeDataSetLine(item, dataSet); dataSetItems.Add(dataSet); } var data = new LineData(dataSetItems.ToArray()); return(data); }
public void Initialize() { gdo = new GDO(); osc = new Oscillograph(gdo); dataSet = new LineDataSet(); dataSet.LineThickness = 3; dataSet.LineColor = UnityEngine.Color.green; chart.YAxis.MaxAxisValue = VPerDelknob.Value * 5; chart.YAxis.MinAxisValue = -VPerDelknob.Value * 5; V_del.text = Math.Round(VPerDelknob.Value, 2).ToString() + " В/дел"; Ms_del.text = (chart.XAxis.MaxAxisValue / 10).ToString() + " Мс/дел"; }
private void DrawFunction(LineDataSet dataSet) { if (!osc.IsOn) { return; } dataSet.Clear(); var g = osc.Graph; for (int i = 0; i < g.Length; i++) { dataSet.AddEntry(new LineEntry((float)g[i].X, (float)g[i].Y)); } chart.GetChartData().DataSets.Add(dataSet); chart.SetDirty(); }
private LineDataSet CreateLineDataSet(Color mcolor, string mLabel) { LineDataSet set = new LineDataSet(null, "Data") { AxisDependency = YAxis.AxisDependency.Left, LineWidth = 3f, Color = mcolor, HighlightEnabled = false, Label = mLabel }; set.SetDrawValues(false); set.SetDrawCircles(false); set.SetMode(LineDataSet.Mode.CubicBezier); set.CubicIntensity = 0.2f; return(set); }
private void CreateGlucoseChart() { if (_bloodGlucoseDataList.Count == 0) { _lineChart.Data.ClearValues(); _lineChart.Clear(); _lineChart.Invalidate(); return; } var glucoseEntries = _bloodGlucoseDataList.Select((t, i) => new BarEntry(i, t.Avg)).Cast <Entry>().ToList(); var glucoseDataSet = new LineDataSet(glucoseEntries, "Glucoza") { ValueTextSize = 14f, ValueTextColor = Color.White, LineWidth = 3f, AxisDependency = YAxis.AxisDependency.Left }; glucoseDataSet.SetMode(LineDataSet.Mode.HorizontalBezier); glucoseDataSet.SetColors(Resources.GetColor(Resource.Color.accent, Theme)); glucoseDataSet.SetCircleColor(Resources.GetColor(Resource.Color.accent, Theme)); var barData = new LineData(glucoseDataSet); _lineChart.Data = barData; _lineChart.SetOnChartValueSelectedListener(this); _lineChart.SetDrawBorders(false); _lineChart.SetDrawGridBackground(false); _lineChart.SetNoDataText("Nu exista date"); _lineChart.Description.Enabled = false; _lineChart.AxisLeft.SetDrawGridLines(false); _lineChart.AxisRight.SetDrawGridLines(false); _lineChart.XAxis.SetDrawGridLines(false); _lineChart.XAxis.Enabled = false; _lineChart.AxisLeft.Enabled = false; _lineChart.AxisRight.Enabled = false; _lineChart.AnimateXY(3000, 3000); // animate horizontal and vertical 3000 milliseconds _lineChart.SetPinchZoom(false); SetLegend(); _lineChart.Invalidate(); }
//--------------------------------------------------------------------------------------------------------------------------------------------------- public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View TabGraphHeight = inflater.Inflate(Resource.Layout.tab_products_GraphHeight, null); base.OnCreateView(inflater, container, savedInstanceState); //Element from the layout. LineChart Graph = TabGraphHeight.FindViewById <LineChart>(Resource.Id.Graph); Graph.SetBackgroundColor(Color.LightGray); //If the user is choosed. if (Classes.User.CurrentUser != -1) { //Creating lists for data, which is going to be shown. List <DateTime> UserDateList = new List <DateTime>(); List <Entry> EntryList = new List <Entry>(); //Getting parameters of currrent user from DB. int k = 1; foreach (ParametresOfUser TempParametres in database_User.GetUser(User.CurrentUser).Parameters) { EntryList.Add(new Entry((k++), (float)TempParametres.Height)); UserDateList.Add(TempParametres.EntryDate); } //Setting data to the graph. LineDataSet DataSet = new LineDataSet(EntryList, Resources.GetString(Resource.String.Parameterscolumn_Height)); DataSet.SetMode(LineDataSet.Mode.CubicBezier); LineData InfoAboutGraph = new LineData(DataSet); Graph.Data = InfoAboutGraph; Graph.Invalidate(); } //If the user isn't choosed. else { Toast.MakeText(Application.Context, Resource.String.ErrorMessage_Unchoosed, ToastLength.Long).Show(); } return(TabGraphHeight); }
private void OnIntializeDataSetLine(ILineDataSetXF source, LineDataSet original) { OnSettingsLineRadarDataSet(source, original); if (source.IF_GetMode().HasValue) { original.SetMode(GetDrawLineMode(source.IF_GetMode().Value)); } if (source.IF_GetCircleColors() != null && source.IF_GetCircleColors().Count > 0) { original.SetCircleColors(source.IF_GetCircleColors().Select(item => item.ToAndroid().ToArgb()).ToArray()); } if (source.IF_GetCircleHoleColor().HasValue) { original.CircleHoleColor = source.IF_GetCircleHoleColor().Value.ToAndroid(); } if (source.IF_GetCircleRadius().HasValue) { original.CircleRadius = source.IF_GetCircleRadius().Value; } if (source.IF_GetCircleHoleRadius().HasValue) { original.CircleHoleRadius = source.IF_GetCircleHoleRadius().Value; } if (source.IF_GetCubicIntensity().HasValue) { original.CubicIntensity = source.IF_GetCubicIntensity().Value; } if (source.IF_GetDrawCircles().HasValue) { original.SetDrawCircles(source.IF_GetDrawCircles().Value); } if (source.IF_GetDrawCircleHole().HasValue) { original.SetDrawCircleHole(source.IF_GetDrawCircleHole().Value); } }
/// <summary> /// Adds the points to entries and to line data set /// </summary> private void AddPointsToEntries() { int count = 0; Random rand = new Random(); foreach (KeyValuePair <string, List <DataPoint> > dp in mCurVisData.Points) { this.mEntries = new List <Entry>(); mColors = new List <int>(); Color col = new Color(rand.NextInt(255), rand.NextInt(255), rand.NextInt(255)); foreach (DataPoint dp2 in dp.Value) { mEntries.Add(new Entry(dp2.X, dp2.Y)); if (mCurVisData.AltControlTime.Any(x => x == dp2.X)) { mColors.Add(Color.Black); } else { mColors.Add(col); } } LineDataSet lds = new LineDataSet(mEntries, dp.Key); lds.SetColor(col, 255); // lds.SetColors(mColors.ToArray()); lds.SetCircleColors(mColors.ToArray()); // lds.SetCircleColor(mColorList[count]); lds.SetDrawCircleHole(true); lds.SetCircleColorHole(col); mDataSet.SetValue(lds, count); count++; } }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.SessionData); // Layout have a object in which the chart will be displayed // Referencing that object lineChart = (LineChart)FindViewById(Resource.Id.linechart); List <Entry> yVals = new List <Entry>(); double j = 0; for (int i = 0; i < 1000; i++) { // float x1 = float.Parse((Math.Sin(x)).ToString()); float y = float.Parse((Math.Sin(j).ToString())); j++; yVals.Add(new Entry(i, y)); } // Data for Ine Chart is set LineDataSet sety = new LineDataSet(yVals, "yData"); // Enables chart to be clear sety.SetDrawCircles(false); // Displays scrollable chart sety.SetMode(LineDataSet.Mode.CubicBezier); // hides the x and y values for each point sety.SetDrawValues(false); LineData data = new LineData(sety); lineChart.Data = (data); lineChart.SetVisibleXRangeMaximum(65f); // Sets the background color lineChart.SetBackgroundColor(Color.FloralWhite); // Grid lines are made invisible lineChart.SetDrawGridBackground(false); }
public LineDataSet GetDataPoints(int moodListID, DateTime startDate, DateTime endDate, string moodName) { //data points for a particular Mood List <Entry> moodPoints = new List <Entry>(); DateTime previousDate = new DateTime(); float runningPointTotal = 0; int sameDayEntryCount = 0; DateTime currentPassDate = new DateTime(); int theXIndex = 0; Globals dbHelp = new Globals(); dbHelp.OpenDatabase(); var sqlDatabase = dbHelp.GetSQLiteDatabase(); if (sqlDatabase == null) { Log.Error(TAG, "GetDataPoints: Uable to retrieve connection to database"); return(null); } try { var sql = "SELECT [MoodRating], [RecordDate] FROM vwCompleteMoodsRating WHERE ([RecordDate] BETWEEN '" + string.Format("{0:yyyy-MM-dd}", startDate) + " 00:00:00' AND '" + string.Format("{0:yyyy-MM-dd}", endDate) + " 23:59:59') AND ([MoodListID] = " + moodListID + ") ORDER BY [RecordDate];"; if (sqlDatabase != null && sqlDatabase.IsOpen) { var moodDataPoints = sqlDatabase.RawQuery(sql, null); if (moodDataPoints.Count > 0) { PadMissingEntriesForMoodInDateRange(startDate, endDate, moodDataPoints); //If there is more than 1 data point for this mood for a particular date, then we need to average it //rather than add more than 1 data point (this will cause an exception otherwise) previousDate = Convert.ToDateTime(_moodDataPoints[0].RecordDate); foreach (var a in _moodDataPoints) { try { Log.Info(TAG, "GetDataPoints: Previous date on iteration " + a.ToString() + " is " + previousDate.ToShortDateString()); currentPassDate = Convert.ToDateTime(a.RecordDate); Log.Info(TAG, "GetDataPoints: Current pass date is " + currentPassDate.ToShortDateString()); if (previousDate != currentPassDate) { //unequal means that we can save a point Log.Info(TAG, "GetDataPoints: Dates don't match - creating new data point from Running Total " + runningPointTotal.ToString() + ", number of entries for this date - " + sameDayEntryCount.ToString()); var theYPoint = runningPointTotal / sameDayEntryCount; if (theYPoint != 0) { Entry thePoint = new Entry(theYPoint, theXIndex); moodPoints.Add(thePoint); } Log.Info(TAG, "GetDataPoints: Added data point " + theYPoint.ToString() + " for date " + previousDate.ToShortDateString()); runningPointTotal = a.MoodRating; sameDayEntryCount = 1; theXIndex++; Log.Info(TAG, "GetDataPoints: X index is now " + theXIndex.ToString()); } else { //current Pass date and previous date are equal, meaning there is more than 1 data point //we will store these points and take an average before we finalise the value for an entry //Note: Since we are using the '1' value as a padding value, if there is padding required AFTER the date //of a data point, they act as additional entries for the date last processed with a value. //The upshot of this is explained as follows: //Say we have a last data point for the date range of 29 //The following day does not have an entry, so a 'padding' entry of '1' is created //This is then added erroneously to the current data point, giving 2 data points with total of 29 + 1 = 30 //This is then averaged by dividing the total by the number of entries, giving 30 / 2 = 15 - INCORRECT //We will therefore ignore values of '1' as padding until a fix can be found var grabPoint = a.MoodRating; //This conditional is the workaround for the padding bug if (grabPoint > 0) { runningPointTotal += grabPoint; sameDayEntryCount++; Log.Info(TAG, "GetDataPoints: Current date same as previous date - storing Running total of " + runningPointTotal.ToString() + ", number of entries for this date - " + sameDayEntryCount.ToString()); } } } finally { previousDate = currentPassDate; Log.Info(TAG, "GetDataPoints: Previous date set to " + previousDate.ToShortDateString()); } } //there will always be one data point left over to add var theLastYPoint = runningPointTotal / sameDayEntryCount; if (theLastYPoint != 0) { Entry thePoint = new Entry(theLastYPoint, theXIndex); moodPoints.Add(thePoint); } Log.Info(TAG, "GetDataPoints: Added final point of " + theLastYPoint.ToString() + " at x index of " + theXIndex.ToString()); //now create the line dataset object to hold our points LineDataSet moodDataSet = new LineDataSet(moodPoints, moodName); //and the axis to plot against moodDataSet.AxisDependency = YAxis.AxisDependency.Left; Log.Info(TAG, "GetDataPoints: Returning " + moodPoints.Count.ToString() + " data points"); if (sqlDatabase.IsOpen) { sqlDatabase.Close(); } return(moodDataSet); } } if (sqlDatabase.IsOpen) { sqlDatabase.Close(); } return(null); } catch (Exception e) { if (sqlDatabase != null && sqlDatabase.IsOpen) { sqlDatabase.Close(); } Log.Error(TAG, "GetDataPoints: Exception - " + e.Message); throw new Exception("Unable to get Data Point for Chart - " + e.Message, e); } }
public LineChart SetupChartData(DateTime startDate, DateTime endDate) { //when first entered into this activity the default is the past weeks data, so we need to get that Globals dbHelp = null; try { if (_lineChart != null) { Log.Info(TAG, "SetupChartData: Found _progressChart"); DateTime loopDate = startDate; //this next array will contain the string labels for the X axis, which is the date of the point List <string> pointsDates = new List <string>(); if (GlobalData.MoodListItems != null) { dbHelp = new Globals(); dbHelp.OpenDatabase(); LineDataSet moodDataSet = null; List <ILineDataSet> moodLineDataSets = new List <ILineDataSet>(); var daysDifference = endDate.Subtract(startDate).Days; Log.Info(TAG, "SetupChartData: Attempting to get " + daysDifference.ToString() + " days data from " + startDate.ToShortDateString() + " to " + endDate.ToShortDateString()); for (var a = 0; a <= daysDifference; a++) { pointsDates.Add(loopDate.ToShortDateString()); Log.Info(TAG, "SetupChartData: Added '" + loopDate.ToShortDateString() + " to date list"); loopDate = loopDate.AddDays(1); } Log.Info(TAG, "SetupChartData: MoodListItems global list contains " + GlobalData.MoodListItems.Count.ToString() + " items"); foreach (var item in GlobalData.MoodListItems) { Log.Info(TAG, "SetupChartData: Attempting to retrieve data points for " + item.MoodName.Trim()); moodDataSet = GetDataPoints(item.MoodId, startDate, endDate, item.MoodName); if (moodDataSet != null) { int[] colorList = new int[1] { GlobalData.ColourList[item.MoodId - 1] }; moodDataSet.SetColors(colorList); moodLineDataSets.Add(moodDataSet); Log.Info(TAG, "SetupChartData: Added " + item.MoodName + " to data sets list"); } else { Log.Info(TAG, "SetupChartData: No data set returned for " + item.MoodName + "!"); } } LineData moodLineData = new LineData(pointsDates, moodLineDataSets); Log.Info(TAG, "SetupChartData: Created LineData containing date list and mood data sets"); _lineChart.Data = moodLineData; _lineChart.Legend.WordWrapEnabled = true; _lineChart.SetDescriptionColor(Color.White); _lineChart.SetDescription(_activity.GetString(Resource.String.MyProgressGraphDescription) + " " + startDate.ToShortDateString() + " - " + endDate.ToShortDateString()); _lineChart.XAxis.TextColor = Color.White; _lineChart.XAxis.AxisLineColor = Color.White; _lineChart.XAxis.GridColor = Color.White; _lineChart.AxisLeft.AxisLineColor = Color.White; _lineChart.AxisRight.AxisLineColor = Color.White; _lineChart.AxisLeft.GridColor = Color.White; _lineChart.AxisRight.GridColor = Color.White; _lineChart.AxisLeft.TextColor = Color.White; _lineChart.AxisRight.TextColor = Color.White; _lineChart.AxisLeft.TextSize = 10f; _lineChart.AxisRight.TextSize = 10f; var yaxis1 = _lineChart.GetAxis(YAxis.AxisDependency.Left); yaxis1.AxisLineColor = Color.White; yaxis1.GridColor = Color.White; yaxis1.TextColor = Color.White; yaxis1.TextSize = 10f; var yaxis2 = _lineChart.GetAxis(YAxis.AxisDependency.Right); yaxis2.AxisLineColor = Color.White; yaxis2.GridColor = Color.White; yaxis2.TextColor = Color.White; yaxis1.TextSize = 10f; _lineChart.SetBorderColor(Color.White); moodLineData.SetValueTextColor(Color.White); moodLineData.SetValueTextSize(10f); _lineChart.Invalidate(); dbHelp.CloseDatabase(); Log.Info(TAG, "SetupChartData: Finished retrieving chart data"); } } } catch (Exception e) { if (dbHelp != null) { if (dbHelp.GetSQLiteDatabase().IsOpen) { dbHelp.CloseDatabase(); } } Log.Error(TAG, "SetupChartData: Exception - " + e.Message); if (GlobalData.ShowErrorDialog) { ErrorDisplay.ShowErrorAlert(_activity, e, "Setting data for chart", "ProgressChartHelper.SetupChartData"); } } return(_lineChart); }
private void ChartsPage_Load(object sender, EventArgs e) { LineDataSet lineDataSet1 = new LineDataSet(); LineDataSet lineDataSet2 = new LineDataSet(); BarDataSet barDataSet1 = new BarDataSet(); RadarDataSet radarDataSet1 = new RadarDataSet(); PolarAreaDataSet polarAreaDataSet1 = new PolarAreaDataSet(); DoughnutDataSet doughnutDataSet1 = new DoughnutDataSet(); PieDataSet pieDataSet1 = new PieDataSet(); lineDataSet1.BackgroundColor = Color.FromArgb(70, 255, 189, 0); lineDataSet1.BorderColor = Color.FromArgb(255, 46, 0); lineDataSet1.Data = new object[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 }; lineDataSet1.PointBorderColor = new[] { Color.FromArgb(0, 255, 0) }; lineDataSet1.PointBackgroundColor = new[] { Color.FromArgb(0, 255, 0) }; lineDataSet1.Fill = true; lineDataSet1.Label = "Data Set"; lineDataSet2.BorderColor = Color.FromArgb(0, 86, 255); lineDataSet2.Data = new object[] { 1, 2, 4, 8, 16, 32, 64, 32, 16, 8, 4, 2 }; lineDataSet2.Label = "Data Set 2"; lineDataSet2.PointStyle = new[] { PointStyle.RectRounded }; lineDataSet2.SteppedLine = SteppedLine.After; chartJS1.DataSets.Add(lineDataSet1); chartJS1.DataSets.Add(lineDataSet2); barDataSet1.BackgroundColor = new[] { Color.FromArgb(49, 255, 0, 0), Color.FromArgb(58, 102, 255, 0), Color.FromArgb(52, 0, 183, 255), Color.FromArgb(53, 247, 0, 255), Color.FromArgb(52, 191, 123, 63), Color.FromArgb(53, 191, 63, 86), Color.FromArgb(104, 255, 0, 118), Color.FromArgb(237, 130, 237), Color.FromArgb(88, 64, 224, 208), Color.FromArgb(84, 255, 98, 70), Color.FromArgb(60, 41, 69, 70), Color.FromArgb(98, 0, 0, 128) }; barDataSet1.BorderColor = null; barDataSet1.Data = new object[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 }; barDataSet1.HoverBackgroundColor = null; barDataSet1.Label = "Data Set"; chartJS2.DataSets.Add(barDataSet1); radarDataSet1.BackgroundColor = Color.FromArgb(72, 79, 191, 63); radarDataSet1.Data = new object[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 }; radarDataSet1.Label = "Data Set"; chartJS4.DataSets.Add(radarDataSet1); polarAreaDataSet1.BackgroundColor = new[] { Color.FromArgb(49, 255, 0, 0), Color.FromArgb(58, 102, 255, 0), Color.FromArgb(52, 0, 183, 255), Color.FromArgb(53, 247, 0, 255), Color.FromArgb(52, 191, 123, 63), Color.FromArgb(53, 191, 63, 86), Color.FromArgb(104, 255, 0, 118), Color.FromArgb(237, 130, 237), Color.FromArgb(88, 64, 224, 208), Color.FromArgb(84, 255, 98, 70), Color.FromArgb(60, 41, 69, 70), Color.FromArgb(98, 0, 0, 128) }; polarAreaDataSet1.BorderColor = null; polarAreaDataSet1.Data = new object[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 0 }; polarAreaDataSet1.HoverBackgroundColor = null; polarAreaDataSet1.Label = "Data Set"; chartJS6.DataSets.Add(polarAreaDataSet1); doughnutDataSet1.BackgroundColor = new[] { Color.FromArgb(49, 255, 0, 0), Color.FromArgb(58, 102, 255, 0), Color.FromArgb(52, 0, 183, 255), Color.FromArgb(53, 247, 0, 255), Color.FromArgb(52, 191, 123, 63), Color.FromArgb(53, 191, 63, 86), Color.FromArgb(104, 255, 0, 118), Color.FromArgb(237, 130, 237), Color.FromArgb(88, 64, 224, 208), Color.FromArgb(84, 255, 98, 70), Color.FromArgb(60, 41, 69, 70), Color.FromArgb(98, 0, 0, 128) }; doughnutDataSet1.BorderColor = null; doughnutDataSet1.Data = new object[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 0 }; doughnutDataSet1.HoverBackgroundColor = null; doughnutDataSet1.Label = "Data Set"; chartJS5.DataSets.Add(doughnutDataSet1); pieDataSet1.BackgroundColor = new[] { Color.FromArgb(49, 255, 0, 0), Color.FromArgb(58, 102, 255, 0), Color.FromArgb(52, 0, 183, 255), Color.FromArgb(53, 247, 0, 255), Color.FromArgb(52, 191, 123, 63), Color.FromArgb(53, 191, 63, 86), Color.FromArgb(104, 255, 0, 118), Color.FromArgb(237, 130, 237), Color.FromArgb(88, 64, 224, 208), Color.FromArgb(84, 255, 98, 70), Color.FromArgb(60, 41, 69, 70), Color.FromArgb(98, 0, 0, 128) }; pieDataSet1.BorderColor = null; pieDataSet1.Data = new object[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 }; pieDataSet1.HoverBackgroundColor = null; pieDataSet1.Label = "Data Set"; chartJS3.DataSets.Add(pieDataSet1); Randomize(); }
public LineChartSample() { InitializeComponent(); var dataSets = new LineDataSet[] { new LineDataSet(new Entry[] { new Entry(0, 0), new Entry(10, 10), new Entry(20, 20), new Entry(30, 25), new Entry(40, 15), new Entry(50, 40), new Entry(60, 12), }, "Sample1") { ValueFormatter = null, Mode = LineDataSet.LineMode.CubicBezier, ValueTextColor = SKColors.Black, DrawFilled = true, Color = Color1, FillColor = Color1, }.EnableDashedHighlightLine(10f, 10f, 0), new LineDataSet(new Entry[] { new Entry(0, 0), new Entry(5, 10), new Entry(15, 20), new Entry(25, 22), new Entry(40, 15), new Entry(50, 30), new Entry(60, 12), }, "Sample2") { ValueFormatter = null, Mode = LineDataSet.LineMode.CubicBezier, ValueTextColor = SKColors.Black, DrawFilled = true, Color = Color2, FillColor = Color2, }.EnableDashedHighlightLine(10f, 10f, 0) }; LineData data = new LineData(dataSets); data.NotifyDataChanged(); var xAxis = Chart.XAxis; xAxis.AxisRange = 100; xAxis.SpaceMax = 1; var axisLeft = Chart.AxisLeft; axisLeft.AxisMaximum = 50; axisLeft.DrawLimitLinesBehindData = true; axisLeft.LimitLines.Add(new LimitLine(10, "Max") .EnableDashedLine(10f, 10f, 0)); axisLeft.LimitLines.Add(new LimitLine(0, "Min") .EnableDashedLine(10f, 10f, 0)); Chart.AxisRight.IsEnabled = false; Chart.Legend.Form = Form.Circle; Chart.Data = data; Chart.Marker = new MarkerViewXY(); Chart.XAxis.ResetAxisMaximum(); Chart.SetVisibleYRange(50, 10, YAxisDependency.Left); Chart.NotifyDataSetChanged(); }
public MainWindow() { InitializeComponent(); var entries = new Entry[] { new Entry(0, 0), new Entry(10, 13), new Entry(15, 10), new Entry(20, 4), new Entry(25, 8) }; var dataSets = new LineDataSet[] { new LineDataSet(entries, "Sample") { Mode = LineDataSet.LineMode.CubicBezier, ValueTextColor = SKColors.Black, DrawFilled = true, Fill = new GradientFill(SKColor.Parse("#266489"), SKColor.Parse("#68B9C0")), }.EnableDashedHighlightLine(10f, 10f, 0) }; LineData data = new LineData(dataSets); data.NotifyDataChanged(); var content = new LineChart() { Marker = new XF.ChartLibrary.Components.MarkerText(), MaxVisibleCount = 3, Data = data, VisibleXRangeMaximum = 15, VisibleXRangeMinimum = 5, XAxis = { SpaceMax = 1, GranularityEnabled = true, }, AxisLeft = { AxisMaximum = 30, LimitLines = { new XF.ChartLibrary.Components.LimitLine(10, "Max") .EnableDashedLine(10f, 10f, 0), new XF.ChartLibrary.Components.LimitLine(0, "Min") .EnableDashedLine(10f, 10f, 0), } }, AxisRight = { IsEnabled = false }, Legend = { Form = XF.ChartLibrary.Components.Form.Line } }; content.SetVisibleYRange(15, 5, XF.ChartLibrary.Components.YAxisDependency.Left); content.NotifyDataSetChanged(); Root.Content = content; }
private View CreateAiringScoreProgressionView( List <MediaTrend> trends) { var detailView = LayoutInflater.Inflate(Resource.Layout.View_AniListObjectDetail, null); var detailContainer = detailView.FindViewById <LinearLayout>(Resource.Id.AniListObjectDetail_InnerContainer); detailView.FindViewById <TextView>(Resource.Id.AniListObjectDetail_Name).Text = "Airing Score Progression"; var chartHeight = Resources.GetDimensionPixelSize(Resource.Dimension.Details_ChartHeight); var textColor = GetThemedColor(Resource.Attribute.Background_Text); var legendMargin = Resources.GetDimensionPixelSize(Resource.Dimension.Details_MarginSmall); detailContainer.SetPadding(legendMargin, 0, legendMargin, 0); var typedColorArray = Resources.ObtainTypedArray(Resource.Array.Chart_Colors); var colorList = new List <int>(); for (var i = 0; i < typedColorArray.Length(); i++) { colorList.Add(typedColorArray.GetColor(i, 0)); } var scoresChart = new LineChart(this) { LayoutParameters = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MatchParent, chartHeight), }; var data = new LineData(); var scorePoints = trends.Select(x => new Entry(x.Episode.Value, x.AverageScore ?? 0)).ToList(); var scoreDataSet = new LineDataSet(scorePoints, "Score") { Color = colorList[0], ValueFormatter = new ChartUtils.IntegerValueFormatter(), }; scoreDataSet.ValueTextSize = 12; scoreDataSet.SetDrawCircleHole(false); scoreDataSet.SetCircleColor(colorList[0]); scoreDataSet.SetMode(LineDataSet.Mode.Linear); scoreDataSet.ValueTextColor = textColor; scoreDataSet.SetDrawValues(true); data.AddDataSet(scoreDataSet); scoresChart.Data = data; scoresChart.FitScreen(); scoresChart.SetTouchEnabled(false); scoresChart.Description.Enabled = false; scoresChart.XAxis.Position = XAxis.XAxisPosition.Bottom; scoresChart.XAxis.ValueFormatter = new ChartUtils.AxisValueCeilingFormatter(1); scoresChart.XAxis.Granularity = 1; scoresChart.XAxis.AxisMaximum = trends.Max(x => x.Episode.Value); scoresChart.XAxis.AxisMinimum = trends.Min(x => x.Episode.Value); scoresChart.XAxis.SetLabelCount(trends.Count, true); scoresChart.AxisLeft.AxisMinimum = 0; scoresChart.AxisLeft.AxisMaximum = 100; scoresChart.Legend.Enabled = false; scoresChart.SetDrawGridBackground(false); scoresChart.XAxis.SetDrawGridLines(false); scoresChart.AxisLeft.Enabled = false; scoresChart.AxisRight.Enabled = false; scoresChart.ExtraLeftOffset = scoresChart.ExtraRightOffset = 15; scoresChart.XAxis.TextColor = scoresChart.AxisLeft.TextColor = scoresChart.Legend.TextColor = textColor; detailContainer.AddView(scoresChart); return(detailView); }
private void CreateBloodPresureChart() { if (_bloodPressureDataList.Count == 0) { _lineChart.Data.ClearValues(); _lineChart.Clear(); _lineChart.Invalidate(); return; } var systolicEntries = new List <Entry>(); var diastolicEntries = new List <Entry>(); for (var i = 0; i < _bloodPressureDataList.Count; i++) { systolicEntries.Add(new BarEntry(i, _bloodPressureDataList[i].Systolic)); diastolicEntries.Add(new BarEntry(i, _bloodPressureDataList[i].Diastolic)); } var systolicDataSet = new LineDataSet(systolicEntries, "Sistola") { ValueTextSize = 14f, ValueTextColor = Color.White, LineWidth = 3f, AxisDependency = YAxis.AxisDependency.Left }; systolicDataSet.SetMode(LineDataSet.Mode.HorizontalBezier); systolicDataSet.SetColors(Resources.GetColor(Resource.Color.accent, Theme)); systolicDataSet.SetCircleColor(Resources.GetColor(Resource.Color.accent, Theme)); var diastolicDataSet = new LineDataSet(diastolicEntries, "Diastola") { ValueTextSize = 14f, ValueTextColor = Color.White, LineWidth = 3f, AxisDependency = YAxis.AxisDependency.Left }; diastolicDataSet.SetMode(LineDataSet.Mode.HorizontalBezier); diastolicDataSet.SetColors(Color.White); diastolicDataSet.SetCircleColor(Color.White); var barData = new LineData(systolicDataSet, diastolicDataSet); _lineChart.Data = barData; _lineChart.SetOnChartValueSelectedListener(this); _lineChart.SetDrawBorders(false); _lineChart.SetDrawGridBackground(false); _lineChart.SetNoDataText("Nu exista date"); _lineChart.Description.Enabled = false; _lineChart.AxisLeft.SetDrawGridLines(false); _lineChart.AxisRight.SetDrawGridLines(false); _lineChart.XAxis.SetDrawGridLines(false); _lineChart.XAxis.Enabled = false; _lineChart.AxisLeft.Enabled = false; _lineChart.AxisRight.Enabled = false; _lineChart.AnimateXY(1000, 1000); // animate horizontal and vertical 3000 milliseconds _lineChart.SetPinchZoom(false); SetLegend(); _lineChart.Invalidate(); }
private View CreateRecentActivityView( List <MediaTrend> trends) { var detailView = LayoutInflater.Inflate(Resource.Layout.View_AniListObjectDetail, null); var detailContainer = detailView.FindViewById <LinearLayout>(Resource.Id.AniListObjectDetail_InnerContainer); detailView.FindViewById <TextView>(Resource.Id.AniListObjectDetail_Name).Text = "Recent Activity"; var chartHeight = Resources.GetDimensionPixelSize(Resource.Dimension.Details_ChartHeight); var textColor = GetThemedColor(Resource.Attribute.Background_Text); var legendMargin = Resources.GetDimensionPixelSize(Resource.Dimension.Details_MarginSmall); detailContainer.SetPadding(legendMargin, 0, legendMargin, 0); var typedColorArray = Resources.ObtainTypedArray(Resource.Array.Chart_Colors); var colorList = new List <int>(); for (var i = 0; i < typedColorArray.Length(); i++) { colorList.Add(typedColorArray.GetColor(i, 0)); } var activityChart = new LineChart(this) { LayoutParameters = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MatchParent, chartHeight), }; var data = new LineData(); var activityPoints = trends.Select(x => new Entry(x.Date, x.Trending)).ToList(); var activityDataSet = new LineDataSet(activityPoints, "Trending") { Color = colorList[0], ValueFormatter = new ChartUtils.NumberValueFormatter(), }; var activityRange = trends.Max(x => x.Trending) - trends.Min(x => x.Trending); activityDataSet.ValueTextSize = 12; activityDataSet.SetDrawCircleHole(false); activityDataSet.SetCircleColor(colorList[0]); activityDataSet.SetMode(LineDataSet.Mode.Linear); activityDataSet.ValueTextColor = textColor; activityDataSet.SetDrawValues(true); data.AddDataSet(activityDataSet); activityChart.Data = data; activityChart.FitScreen(); activityChart.SetTouchEnabled(false); activityChart.Description.Enabled = false; activityChart.XAxis.Position = XAxis.XAxisPosition.Bottom; activityChart.XAxis.ValueFormatter = new ChartUtils.DateValueFormatter("MMM d"); activityChart.XAxis.LabelRotationAngle = 60; activityChart.XAxis.Granularity = 1; activityChart.XAxis.AxisMaximum = trends.Max(x => x.Date); activityChart.XAxis.AxisMinimum = trends.Min(x => x.Date); activityChart.XAxis.SetLabelCount(trends.Count, true); activityChart.AxisLeft.AxisMinimum = Math.Max(trends.Min(x => x.Trending) - activityRange / 2, 0); activityChart.AxisLeft.AxisMaximum = trends.Max(x => x.Trending) + activityRange / 2; activityChart.Legend.Enabled = false; activityChart.SetDrawGridBackground(false); activityChart.XAxis.SetDrawGridLines(false); activityChart.AxisLeft.Enabled = false; activityChart.AxisRight.Enabled = false; activityChart.XAxis.TextColor = activityChart.AxisLeft.TextColor = activityChart.Legend.TextColor = textColor; activityChart.ExtraLeftOffset = activityChart.ExtraRightOffset = 15; detailContainer.AddView(activityChart); return(detailView); }