예제 #1
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,
            };
        }
예제 #2
0
        async Task Chart6Calcul(List <SkiaSharp.SKColor> colorTab)
        {
            //-------------------------------------------------------------------------------------------------------------------------------------------
            //---------------------------------------------Chart 5 Acquereurs sources
            //---------------------------------------------------------------Chart 5 Leads Sources---------------------------

            var clientsSources = await StoreManager.NoteStore.GetSourcesStat(Qualification.Client, dateDeb, dateFin);

            if (clientsSources != null && clientsSources.Any())
            {
                //List de contact
                List <Contact> contactList = new List <Contact>();

                foreach (var itemS in clientsSources)
                {
                    var contact = await StoreManager.ContactStore.GetItemAsync(itemS.ContactId);

                    if (contact != null)
                    {
                        contactList.Add(contact);
                    }
                }
                long totalContact = contactList.Count();
                var  tri          = contactList.GroupBy(x => x.CollectSourceName)
                                    .Select(g => new SourcesStats
                {
                    Total      = (g.Count() * 100) / totalContact,
                    SourceName = g.Key
                })
                                    .OrderBy(g => g.SourceName);



                if (tri != null && tri.Any())
                {
                    Chart6Visible = true;
                    var entriesClient = new List <Microcharts.Entry>();

                    var   k = 0;
                    float percentClientAutre = 0;
                    foreach (var item in tri)
                    {
                        if (item.Total > 0)
                        {
                            if (item.Total < 5)
                            {
                                percentClientAutre += item.Total;
                            }
                            else
                            {
                                entriesClient.Add(
                                    new Microcharts.Entry(item.Total)
                                {
                                    Label      = item.SourceName,
                                    ValueLabel = item.Total + "%",
                                    Color      = colorTab[k],
                                });
                                k++;
                            }
                        }
                    }
                    if (percentClientAutre > 0)
                    {
                        entriesClient.Add(
                            new Microcharts.Entry(percentClientAutre)
                        {
                            Label      = "Autres",
                            ValueLabel = percentClientAutre + "%",
                            Color      = colorTab[k],
                        });
                    }
                    Chart6 = new Microcharts.DonutChart {
                        Entries = entriesClient, HoleRadius = 0.50f
                    };
                }
            }
        }
예제 #3
0
        async Task Chart2Calcul(List <SkiaSharp.SKColor> colorTab)
        {
            //----------------------------------------------------------------------------------------------------------------------
            //--------------------------Chart Sources d'acquisitions - Chart2----------------------------------------------------------------


            //liste des collectSource
            var collectSources = await StoreManager.CollectSourceStore.GetItemsAsync();

            if (collectSources != null && collectSources.Any())
            {
                Chart2Visible = true;
                // collectSource general
                var entriesCollect = new List <Microcharts.Entry>();

                //nbre total de contact
                var contacts = await StoreManager.ContactStore.GetItemsAsync();

                long totalContacts = (contacts as IQueryResultEnumerable <Contact>).TotalCount;

                var   i            = 0;
                float percentAutre = 0;
                foreach (var cs in collectSources)
                {
                    long total = await StoreManager.ContactStore.GetTotalCountByCollectSourceId(cs.Id);

                    if (total > 0)
                    {
                        float percent = (total * 100) / totalContacts;
                        if (percent < 5)
                        {
                            percentAutre += percent;
                        }
                        else
                        {
                            entriesCollect.Add(
                                new Microcharts.Entry(percent)
                            {
                                Label      = cs.Name,
                                ValueLabel = percent + "%",
                                Color      = colorTab[i],
                            });
                            i++;
                        }
                    }
                }
                if (percentAutre > 0)
                {
                    entriesCollect.Add(
                        new Microcharts.Entry(percentAutre)
                    {
                        Label      = "Autres",
                        ValueLabel = percentAutre + "%",
                        Color      = colorTab[i],
                    });
                }
                Chart2 = new Microcharts.DonutChart {
                    Entries = entriesCollect, HoleRadius = 0.50f
                };
            }
        }