예제 #1
0
        //refreshes the graph
        public void RefreshGraph()
        {
            //setup chart
            List <Microcharts.ChartEntry> entries = new List <Microcharts.ChartEntry>();
            List <int> values = DatabaseHandler.GetDatabase().GetCurrentTracker().GetItemTracker().GetArray().ToList();

            Console.WriteLine("Values: ");
            foreach (int val in values)
            {
                Console.WriteLine(val);
                Microcharts.ChartEntry newEntry = new Microcharts.ChartEntry(val)
                {
                    Color = new SKColor(PageColors.primaryColor.R, PageColors.primaryColor.G, PageColors.primaryColor.B, PageColors.primaryColor.A)
                };

                entries.Add(newEntry);
            }

            lineChart.Chart = new LineChart()
            {
                Entries         = entries,
                BackgroundColor = SKColors.Transparent,
                Margin          = 0,
            };
        }
예제 #2
0
 private void Inner_DrawLineRange(SKCanvas canvas, int seriesIndex, LineStyle lineStyle, SKColor color, Swipe pinchPan)
 {
     if (list.Count > 1)
     {
         using (var paint = new SKPaint {
             Style = SKPaintStyle.Fill,
             Color = color,
             IsAntialias = true,
         }) {
             var        path       = new SKPath();
             ChartEntry entry0     = list[0];
             SKPoint    meanPoint0 = entry0.Ypoint[seriesIndex];
             float      range0     = entry0.YpointRange[seriesIndex];
             path.MoveTo(pinchPan % new SKPoint(meanPoint0.X, meanPoint0.Y + range0));
             path.LineTo(pinchPan % new SKPoint(meanPoint0.X, meanPoint0.Y - range0));
             for (int i = 0; i < list.Count; i++)
             {
                 ChartEntry entry     = list[i];
                 SKPoint    meanPoint = entry.Ypoint[seriesIndex];
                 float      range     = entry.YpointRange[seriesIndex];
                 path.LineTo(pinchPan % new SKPoint(meanPoint.X, meanPoint.Y - range));
             }
             for (int i = list.Count - 1; i >= 0; i--)
             {
                 ChartEntry entry     = list[i];
                 SKPoint    meanPoint = entry.Ypoint[seriesIndex];
                 float      range     = entry.YpointRange[seriesIndex];
                 path.LineTo(pinchPan % new SKPoint(meanPoint.X, meanPoint.Y + range));
             }
             path.Close();
             canvas.DrawPath(path, paint);
         }
     }
 }
예제 #3
0
        private void DrawTooltip(SKCanvas canvas, ChartEntry entry)
        {
            using (var textPaint = new SKPaint
            {
                Style = SKPaintStyle.StrokeAndFill,
                Color = TooltipTextColor,
                TextAlign = SKTextAlign.Center,
                TextSize = TooltipTextSize
            })
            {
                var topBottomMargin      = TooltipTextSize;
                var tooltipTextYPosition = _tooltipPoint.Y - TooltipYOffset - topBottomMargin;
                var textPath             = textPaint.GetTextPath(entry.Label, _tooltipPoint.X, tooltipTextYPosition);
                using (var tooltipBackgroundPaint = new SKPaint
                {
                    Style = SKPaintStyle.StrokeAndFill,
                    Color = TooltipBackgroundColor
                })
                {
                    var leftRightMargin = TooltipTextSize / 2;
                    canvas.DrawRoundRect(new SKRect(textPath.Bounds.Left - leftRightMargin, textPath.Bounds.Top - topBottomMargin, textPath.Bounds.Right + leftRightMargin, textPath.Bounds.Bottom + topBottomMargin), TooltipRadius, TooltipRadius, tooltipBackgroundPaint);
                }

                canvas.DrawText(entry.Label, _tooltipPoint.X, tooltipTextYPosition, textPaint);
            }
        }
예제 #4
0
 public void ClearData()
 {
     lock (mutex) {
         this.list           = new List <ChartEntry>();
         this.lastEntry      = null;
         this.lastEntryCount = 0;
     }
 }
예제 #5
0
        private Dictionary <string, int> seriesIndex;   // maintaining the connection between seriesList and timecourse

        public Timecourse()
        {
            this.mutex          = new object();
            this.seriesList     = new List <Series>();
            this.list           = new List <ChartEntry>();
            this.seriesIndex    = new Dictionary <string, int>();
            this.lastEntry      = null;
            this.lastEntryCount = 0;
        }
예제 #6
0
 public void DrawGaugeArea(SKCanvas canvas, ChartEntry entry, float radius, int cx, int cy, float strokeWidth)
 {
     using (var paint = new SKPaint
     {
         Style = SKPaintStyle.Stroke,
         StrokeWidth = strokeWidth,
         Color = entry.Color.WithAlpha(LineAreaAlpha),
         IsAntialias = true,
     })
     {
         canvas.DrawCircle(cx, cy, radius, paint);
     }
 }
예제 #7
0
 private void Inner_CalculatePoints(SKPoint plotOrigin, SKSize plotSize, float minX, float maxX, float minY, float maxY)
 {
     for (int i = 0; i < list.Count; i++)
     {
         ChartEntry entry  = list[i];
         SKPoint[]  points = new SKPoint[entry.Y.Length];
         float      x      = plotOrigin.X + XlocOfXvalInPlotarea(entry.X, minX, maxX, plotSize);
         for (int j = 0; j < entry.Y.Length; j++)
         {
             var y = plotOrigin.Y + YlocOfYvalInPlotarea(entry.Y[j], minY, maxY, plotSize);
             entry.Ypoint[j]      = new SKPoint(x, y);
             entry.YpointRange[j] = (entry.Yrange[j] == 0) ? 0 : YlocRangeOfYvalRangeInPlotarea(entry.Yrange[j], minY, maxY, plotSize);
         }
     }
 }
예제 #8
0
        private void SliderChanged(object sender, ValueChangedEventArgs e)
        {
            ParamViewModel from = (ParamViewModel)sender;

            for (int q = 0; q < 5; q++)
            {
                if (entries[q].Label == from.Name)
                {
                    int val = Convert.ToInt32(e);
                    entries[q] = new Entry(val)
                    {
                        Label      = entries[q].Label,
                        ValueLabel = entries[q].ValueLabel.ToString(),
                        Color      = entries[q].Color
                    };
                }
            }
        }
예제 #9
0
 public void DrawGaugeArea(SKCanvas canvas, ChartEntry entry, float radius, int cx, int cy, float strokeWidth)
 {
     using (var paint = new SKPaint
     {
         Style = SKPaintStyle.Stroke,
         StrokeWidth = strokeWidth,
         StrokeCap = SKStrokeCap.Round,
         Color = entry.Color.WithAlpha(LineAreaAlpha),
         IsAntialias = true,
     })
     {
         using (SKPath path = new SKPath())
         {
             path.AddArc(SKRect.Create(cx - radius * 2, cy - radius * 2, 4 * radius, 4 * radius), 180, 180);
             canvas.DrawPath(path, paint);
         }
     }
 }
예제 #10
0
 public void DrawGauge(SKCanvas canvas, ChartEntry entry, float radius, int cx, int cy, float strokeWidth)
 {
     using (var paint = new SKPaint
     {
         Style = SKPaintStyle.Stroke,
         StrokeWidth = strokeWidth,
         StrokeCap = SKStrokeCap.Round,
         Color = entry.Color,
         IsAntialias = true,
     })
     {
         using (SKPath path = new SKPath())
         {
             var sweepAngle = AnimationProgress * 360 * (Math.Abs(entry.Value) - AbsoluteMinimum) / ValueRange;
             path.AddArc(SKRect.Create(cx - radius, cy - radius, 2 * radius, 2 * radius), StartAngle, sweepAngle);
             canvas.DrawPath(path, paint);
         }
     }
 }
예제 #11
0
        private void DrawDonutChart(List <TaskStatistic> statistics)
        {
            var entries = new List <Microcharts.ChartEntry>();

            Dictionary <Guid, (int count, string name)> taskDictionary = new Dictionary <Guid, (int count, string name)>();

            foreach (var statistic in statistics)
            {
                if (!taskDictionary.ContainsKey(statistic.TaskId))
                {
                    taskDictionary[statistic.TaskId] = (count : 1, name : statistic.TaskName);
                }
                else
                {
                    taskDictionary[statistic.TaskId] = (count : taskDictionary[statistic.TaskId].count + 1, name : taskDictionary[statistic.TaskId].name);
                }
            }

            foreach (var item in taskDictionary)
            {
                var entry = new Microcharts.ChartEntry(item.Value.count)
                {
                    Label      = item.Value.name,
                    ValueLabel = item.Value.count.ToString(),
                    Color      = SKColor.Parse(ColorPickService.GetRandom()),
                };
                entries.Add(entry);
            }

            TaskDonutChart = new Microcharts.DonutChart()
            {
                IsAnimated        = true,
                AnimationDuration = TimeSpan.FromMilliseconds(300),
                LabelTextSize     = 25,
                Entries           = entries,
                BackgroundColor   = SkiaSharp.SKColors.Transparent,
                Margin            = 10,
            };
        }
예제 #12
0
 public void AddRange(string seriesName, float t, float mean, float variance)
 {
     lock (mutex) {
         if (float.IsNaN(mean))
         {
             mean = 0;                               // these have been converted from double
         }
         if (float.IsNaN(variance))
         {
             variance = 0;                           // these have been converted from double
         }
         if (seriesIndex.ContainsKey(seriesName))    // if not, it may be due to a concurrent invocations of plotting before the previous one has finished
         {
             int index = seriesIndex[seriesName];
             if (lastEntry == null)
             {
                 var Y      = new float[seriesList.Count];
                 var Yrange = new float[seriesList.Count];
                 Y[index]       = mean;
                 Yrange[index]  = variance;
                 lastEntry      = new ChartEntry(X: t, Y: Y, Yrange: Yrange);
                 lastEntryCount = 1;
             }
             else
             {
                 lastEntry.Y[index]      = mean;
                 lastEntry.Yrange[index] = variance;
                 lastEntryCount++;
             }
             if (lastEntryCount == seriesList.Count)
             {
                 list.Add(lastEntry);
                 lastEntry      = null;
                 lastEntryCount = 0;
             }
         }
     }
 }
예제 #13
0
        private List <Entry> LoadGraph()
        {
            List <SKColor> colorList = new List <SKColor>();

            colorList.Add(SKColor.Parse("#FF1943"));
            colorList.Add(SKColor.Parse("#00BFFF"));
            colorList.Add(SKColor.Parse("#00CED1"));
            colorList.Add(SKColor.Parse("#FF5733"));
            colorList.Add(SKColor.Parse("#FFC300"));
            colorList.Add(SKColor.Parse("#75FA33"));
            colorList.Add(SKColor.Parse("#9033FF"));
            colorList.Add(SKColor.Parse("#3399FF"));
            colorList.Add(SKColor.Parse("#FF33E1"));
            colorList.Add(SKColor.Parse("#33FF8D"));

            List <Entry> entries = new List <Entry>();

            int index = 0;

            foreach (LogModel i in LogList)
            {
                int   volume = (int)(i.Reps * i.Sets * i.Weights);
                Entry e      = new Entry(volume)
                {
                    ValueLabel = (volume).ToString(),
                    Label      = i.Date,
                    Color      = colorList[index],
                };
                index++;
                entries.Add(e);
                if (index > 10)
                {
                    break;
                }
            }

            return(entries);
        }
예제 #14
0
        private List <Entry> LoadGraph()
        {
            List <SKColor> colorList = new List <SKColor>();

            colorList.Add(SKColor.Parse("#FF1943"));
            colorList.Add(SKColor.Parse("#00BFFF"));
            colorList.Add(SKColor.Parse("#00CED1"));
            colorList.Add(SKColor.Parse("#FF5733"));
            colorList.Add(SKColor.Parse("#FFC300"));
            colorList.Add(SKColor.Parse("#75FA33"));
            colorList.Add(SKColor.Parse("#9033FF"));
            colorList.Add(SKColor.Parse("#3399FF"));
            colorList.Add(SKColor.Parse("#FF33E1"));
            colorList.Add(SKColor.Parse("#33FF8D"));

            List <Entry> entries = new List <Entry>();

            int index = 0;

            foreach (ExerciseModel i in ExerciseList)
            {
                Entry e = new Entry(i.Data.Count())
                {
                    ValueLabel = (i.Data.Count()).ToString(),
                    Label      = i.Name,
                    Color      = colorList[index],
                };
                index++;
                entries.Add(e);
                if (index > 10)
                {
                    break;
                }
            }

            return(entries);
        }
예제 #15
0
        public async Task initAsync()
        {
            /*
             * List<FoodMini> listFood = await firebaseHelper.GetAllFood();
             * int sizeList = 0;
             * if (listFood != null) {
             *  sizeList = listFood.Count;
             * }
             */
            IsBusy = true;

            List <SKColor> listColor = new List <SKColor>();

            listColor.Add(SKColor.Parse("#FF0033"));
            listColor.Add(SKColor.Parse("#FF8000"));
            listColor.Add(SKColor.Parse("#FFE600"));
            listColor.Add(SKColor.Parse("#1AB34D"));
            listColor.Add(SKColor.Parse("#801AB3"));
            listColor.Add(SKColor.Parse("#1A66FF"));
            listColor.Add(SKColor.Parse("#FF0033"));
            listColor.Add(SKColor.Parse("#FF8000"));
            listColor.Add(SKColor.Parse("#FFE600"));
            listColor.Add(SKColor.Parse("#1AB34D"));
            listColor.Add(SKColor.Parse("#801AB3"));
            listColor.Add(SKColor.Parse("#1A66FF"));
            listColor.Add(SKColor.Parse("#FF0033"));
            listColor.Add(SKColor.Parse("#FF8000"));
            listColor.Add(SKColor.Parse("#FFE600"));
            listColor.Add(SKColor.Parse("#1AB34D"));
            listColor.Add(SKColor.Parse("#801AB3"));
            listColor.Add(SKColor.Parse("#1A66FF"));


            string          date_str     = DateTime.Now.ToString("yyyy'-'MM'-'dd", CultureInfo.InvariantCulture).Replace("-", "");
            List <FoodMini> listFoodBack = new List <FoodMini>();

            List <ReportModel> tableList = new List <ReportModel>();



            _entries = new List <Microcharts.ChartEntry>();
            for (int i = 0; i < 8; i++)
            {
                List <FoodMini> listFood1 = await firebaseHelper.GetAllFoodByStatus(date_str, "Y");

                int count_sale = 0;
                if (listFood1 == null)
                {
                    count_sale = 0;
                }
                else
                {
                    count_sale = listFood1.Count();
                }

                Utils       utils   = new Utils();
                ReportModel models1 = new ReportModel();
                models1.DateValue = "วันที่:" + date_str;
                models1.Quantity  = "จำนวน:" + count_sale;
                tableList.Add(models1);
                Microcharts.ChartEntry entry1 = new Microcharts.ChartEntry(count_sale)
                {
                    Label      = utils.convertYYYYMMDD(date_str),
                    ValueLabel = utils.convertYYYYMMDD(date_str),
                    Color      = listColor[i],
                };
                _entries.Add(entry1);


                // listFoodBack.AddRange(listFood1);
                date_str = DateTime.Now.AddDays(-i).ToString("yyyy'-'MM'-'dd", CultureInfo.InvariantCulture).Replace("-", "");
            }


            listSale.ItemsSource = tableList;

            /*
             * List<FoodMini> listFoodBack = new List<FoodMini>();
             * for (int i = sizeList - 1; i >= 0; i--) {
             *  listFoodBack.Add(listFood[i]);
             *
             *
             * }
             */

            /*
             * GFD gg = new GFD();
             *
             * listFood.Sort(gg);
             * _entries = new List<Microcharts.ChartEntry>();
             *
             * for (int i = 0; i < listFood.Count; i++)
             * {
             *  if (i >= 8) {
             *      break;
             *  }
             *  FoodMini mini = listFood[i];
             *
             *  Microcharts.ChartEntry entry1 = new Microcharts.ChartEntry(mini.Quantity)
             *  {
             *      Label = mini.Name,
             *      ValueLabel = mini.OrderDate + "",
             *      Color = listColor[i],
             *  };
             *  _entries.Add(entry1);
             *
             * }
             */
            /*
             * for (int i = 0; i < listFoodBack.Count; i++)
             * {
             *  if (i >= 8)
             *  {
             *      break;
             *  }
             *  FoodMini mini = listFoodBack[i];
             *
             *  Microcharts.ChartEntry entry1 = new Microcharts.ChartEntry(mini.Quantity)
             *  {
             *      Label = mini.Name,
             *      ValueLabel = mini.OrderDate + "",
             *      Color = listColor[i],
             *  };
             *  _entries.Add(entry1);
             *
             * }
             */
            MyBarChart.Chart = new BarChart {
                Entries = _entries
            };

            IsBusy = false;
        }
예제 #16
0
        /// <inheritdoc />
        protected override void DrawValueLabel(SKCanvas canvas, Dictionary <ChartEntry, SKRect> valueLabelSizes, float headerWithLegendHeight, SKSize itemSize, SKSize barSize, ChartEntry entry, float barX, float barY, float itemX, float origin)
        {
            string label = entry?.ValueLabel;

            if (string.IsNullOrEmpty(label))
            {
                return;
            }

            var drawedPoint = new SKPoint(barX - (itemSize.Width / 2) + (barSize.Width / 2), barY);

            if (ValueLabelOption == ValueLabelOption.TopOfChart)
            {
                base.DrawValueLabel(canvas, valueLabelSizes, headerWithLegendHeight, itemSize, barSize, entry, barX, barY, itemX, origin);
            }
            else if (ValueLabelOption == ValueLabelOption.TopOfElement)
            {
                DrawHelper.DrawLabel(canvas, ValueLabelOrientation, ValueLabelOrientation == Orientation.Vertical ? YPositionBehavior.UpToElementHeight : YPositionBehavior.None, barSize, new SKPoint(drawedPoint.X, drawedPoint.Y - (PointSize / 2) - (Margin / 2)), entry.ValueLabelColor.WithAlpha((byte)(255 * AnimationProgress)), valueLabelSizes[entry], label, ValueLabelTextSize, Typeface);
            }
            else if (ValueLabelOption == ValueLabelOption.OverElement)
            {
                DrawHelper.DrawLabel(canvas, ValueLabelOrientation, ValueLabelOrientation == Orientation.Vertical ? YPositionBehavior.UpToElementMiddle : YPositionBehavior.DownToElementMiddle, barSize, new SKPoint(drawedPoint.X, drawedPoint.Y), entry.ValueLabelColor.WithAlpha((byte)(255 * AnimationProgress)), valueLabelSizes[entry], label, ValueLabelTextSize, Typeface);
            }
        }
예제 #17
0
        /// <inheritdoc/>
        protected override void DrawValueLabel(SKCanvas canvas, Dictionary <ChartEntry, SKRect> valueLabelSizes, float headerWithLegendHeight, SKSize itemSize, SKSize barSize, ChartEntry entry, float barX, float barY, float itemX, float origin)
        {
            if (string.IsNullOrEmpty(entry?.ValueLabel))
            {
                return;
            }

            (SKPoint location, SKSize size) = GetBarDrawingProperties(headerWithLegendHeight, itemSize, barSize, 0, barX, barY);
            if (ValueLabelOption == ValueLabelOption.TopOfChart)
            {
                base.DrawValueLabel(canvas, valueLabelSizes, headerWithLegendHeight, itemSize, barSize, entry, barX, barY, itemX, origin);
            }
            else if (ValueLabelOption == ValueLabelOption.TopOfElement)
            {
                DrawHelper.DrawLabel(canvas, ValueLabelOrientation, ValueLabelOrientation == Orientation.Vertical ? YPositionBehavior.UpToElementHeight : YPositionBehavior.None, barSize, new SKPoint(location.X + size.Width / 2, barY - Margin), entry.ValueLabelColor.WithAlpha((byte)(255 * AnimationProgress)), valueLabelSizes[entry], entry.ValueLabel, ValueLabelTextSize, Typeface, AllowValueLabelOverflow);
            }
            else if (ValueLabelOption == ValueLabelOption.OverElement)
            {
                DrawHelper.DrawLabel(canvas, ValueLabelOrientation, ValueLabelOrientation == Orientation.Vertical ? YPositionBehavior.UpToElementMiddle : YPositionBehavior.DownToElementMiddle, barSize, new SKPoint(location.X + size.Width / 2, barY + (origin - barY) / 2), entry.ValueLabelColor.WithAlpha((byte)(255 * AnimationProgress)), valueLabelSizes[entry], entry.ValueLabel, ValueLabelTextSize, Typeface, AllowValueLabelOverflow);
            }
        }
        private async Task UpdateDataAsync()
        {
            try
            {
                var test = new List <float>();

                test.Add(100);
                test.Add(-300);
                test.Add(120);
                test.Add(400);
                test.Add(785);
                test.Add(220);
                test.Add(105);
                test.Add(300);
                test.Add(470);
                test.Add(900);
                test.Add(220);
                test.Add(105);
                test.Add(300);
                test.Add(470);
                test.Add(900);

                Random rnd = new Random();



                foreach (var item in test)
                {
                    var data = new Entry(item)
                    {
                        Color = SkiaSharp.SKColor.Parse(String.Format("#{0:X6}", rnd.Next(0x1000000))),
                        //Color =  SKColor.Parse("#FF1943"),
                        Label      = "Item_" + item,
                        ValueLabel = item.ToString()
                    };

                    if (entries != null)
                    {
                        entries.Add(data);
                    }

                    //remove first data if exceeded from 5 records
                    //if(entries.Count > 5)
                    //{
                    //    entries.RemoveAt(0);
                    //}


                    Chart2.Chart = new LineChart()
                    {
                        Entries               = entries,
                        LineMode              = LineMode.Straight,
                        LineSize              = 8,
                        PointMode             = PointMode.Circle,
                        PointSize             = 18,
                        AnimationDuration     = new TimeSpan(20),
                        AnimationProgress     = 20,
                        IsAnimated            = true,
                        ValueLabelOrientation = Orientation.Horizontal
                    };


                    await Task.Delay(2000);
                }
            }

            catch (Exception ex)
            {
            }
        }
예제 #19
0
 internal static YPositionBehavior ComputeEntryYPositionBehavior(
     ChartEntry entry, YPositionBehavior defaultBehaviour)
 {
     return(entry.ValueLabelYPositionBehavior.GetValueOrDefault(defaultBehaviour));
 }
예제 #20
0
        public async Task initAsync()
        {
            try
            {
                IsBusy = true;
                List <FoodMini> listFood = new List <FoodMini>();
                string          date_str = DateTime.Now.ToString("yyyy'-'MM'-'dd", CultureInfo.InvariantCulture).Replace("-", "");
                for (int i = 1; i <= 30; i++)
                {
                    listFood.AddRange(await firebaseHelper.GetAllFoodByStatus(date_str, "Y"));
                    int d = i * -1;
                    date_str = DateTime.Now.AddDays(d).ToString("yyyy'-'MM'-'dd", CultureInfo.InvariantCulture).Replace("-", "");
                }


                //    List<FoodMini> listFood = await firebaseHelper.GetAllFood();
                List <SKColor> listColor = new List <SKColor>();
                listColor.Add(SKColor.Parse("#FF0033"));
                listColor.Add(SKColor.Parse("#FF8000"));
                listColor.Add(SKColor.Parse("#FFE600"));
                listColor.Add(SKColor.Parse("#1AB34D"));
                listColor.Add(SKColor.Parse("#801AB3"));
                listColor.Add(SKColor.Parse("#1A66FF"));
                listColor.Add(SKColor.Parse("#FF0033"));
                listColor.Add(SKColor.Parse("#FF8000"));
                listColor.Add(SKColor.Parse("#FFE600"));
                listColor.Add(SKColor.Parse("#1AB34D"));
                listColor.Add(SKColor.Parse("#801AB3"));
                listColor.Add(SKColor.Parse("#1A66FF"));
                listColor.Add(SKColor.Parse("#FF0033"));
                listColor.Add(SKColor.Parse("#FF8000"));
                listColor.Add(SKColor.Parse("#FFE600"));
                listColor.Add(SKColor.Parse("#1AB34D"));
                listColor.Add(SKColor.Parse("#801AB3"));
                listColor.Add(SKColor.Parse("#1A66FF"));

                listColor.Add(SKColor.Parse("#FF0033"));
                listColor.Add(SKColor.Parse("#FF8000"));
                listColor.Add(SKColor.Parse("#FFE600"));
                listColor.Add(SKColor.Parse("#1AB34D"));
                listColor.Add(SKColor.Parse("#801AB3"));
                listColor.Add(SKColor.Parse("#1A66FF"));
                listColor.Add(SKColor.Parse("#FF0033"));
                listColor.Add(SKColor.Parse("#FF8000"));
                listColor.Add(SKColor.Parse("#FFE600"));
                listColor.Add(SKColor.Parse("#1AB34D"));
                listColor.Add(SKColor.Parse("#801AB3"));
                listColor.Add(SKColor.Parse("#1A66FF"));
                listColor.Add(SKColor.Parse("#FF0033"));
                listColor.Add(SKColor.Parse("#FF8000"));
                listColor.Add(SKColor.Parse("#FFE600"));


                /*
                 * GFG gg = new GFG();
                 * listFood.Sort(gg);
                 */

                List <FavoritesFoodModel> listFavorites = new List <FavoritesFoodModel>();
                listFavorites = getFavoritesFood(listFood);
                _entries      = new List <Microcharts.ChartEntry>();
                for (int i = 0; i < listFavorites.Count; i++)
                {
                    FavoritesFoodModel mini = listFavorites[i];

                    Microcharts.ChartEntry entry1 = new Microcharts.ChartEntry(mini.Quantity)
                    {
                        Label      = mini.NameEn,
                        ValueLabel = mini.Quantity + "",
                        Color      = listColor[i],
                    };
                    _entries.Add(entry1);
                }

                MyBarChart.Chart = new BarChart {
                    Entries = _entries
                };

                IsBusy = false;
            }
            catch (Exception exx) {
                string error = exx.Message;
                IsBusy = false;
            }
        }
예제 #21
0
 /// <inheritdoc/>
 protected override void DrawValueLabel(SKCanvas canvas, Dictionary <ChartEntry, SKRect> valueLabelSizes, float headerWithLegendHeight, SKSize itemSize, SKSize barSize, ChartEntry entry, float barX, float barY, float itemX, float origin)
 {
     if (Series.Count() == 1 && ValueLabelOption == ValueLabelOption.TopOfChart)
     {
         base.DrawValueLabel(canvas, valueLabelSizes, headerWithLegendHeight, itemSize, barSize, entry, barX, barY, itemX, origin);
     }
 }
예제 #22
0
        public GraphAnalysis()
        {
            InitializeComponent();
            selectedMonth = DateTime.Now.ToString("MMMM");
            Enum.TryParse(selectedMonth, out Month month);
            var ExpensesFromFile = ExpenseManager.GetExpenses();


            foreach (var expense in ExpensesFromFile)
            {
                Entry Entry = new Entry(expense.Amount)
                {
                    Label      = expense.Category.ToString(),
                    ValueLabel = expense.Amount.ToString()
                };
                expensesList.Add(Entry);
            }


            foreach (var entry in expensesList)
            {
                if (entry.Label == ExpenseCategory.Food.ToString())
                {
                    entry.Color           = SKColor.Parse("#00ced1");
                    entry.ValueLabelColor = SKColor.Parse("#00ced1");
                }
                if (entry.Label == ExpenseCategory.Insurance.ToString())
                {
                    entry.Color           = SKColor.Parse("#d100ce");
                    entry.ValueLabelColor = SKColor.Parse("#d100ce");
                }
                if (entry.Label == ExpenseCategory.Medical.ToString())
                {
                    entry.Color           = SKColor.Parse("#ced100");
                    entry.ValueLabelColor = SKColor.Parse("#ced100");
                }
                if (entry.Label == ExpenseCategory.Utilities.ToString())
                {
                    entry.Color           = SKColor.Parse("#d10300");
                    entry.ValueLabelColor = SKColor.Parse("#d10300");
                }
                if (entry.Label == ExpenseCategory.Transportation.ToString())
                {
                    entry.Color           = SKColor.Parse("#cc0000");
                    entry.ValueLabelColor = SKColor.Parse("#cc0000");
                }
                if (entry.Label == ExpenseCategory.Saving.ToString())
                {
                    entry.Color           = SKColor.Parse("#00a5e6");
                    entry.ValueLabelColor = SKColor.Parse("#00a5e6");
                }
                if (entry.Label == ExpenseCategory.Other.ToString())
                {
                    entry.Color           = SKColor.Parse("#008000");
                    entry.ValueLabelColor = SKColor.Parse("#008000");
                }
            }


            Chart1.Chart = new RadialGaugeChart()
            {
                Entries = (IEnumerable <ChartEntry>)expensesList
            };
            Chart2.Chart = new BarChart()
            {
                Entries = (IEnumerable <ChartEntry>)expensesList
            };
            Chart3.Chart = new DonutChart()
            {
                Entries = (IEnumerable <ChartEntry>)expensesList
            };
        }