Ejemplo n.º 1
0
        private void PortfolioResultsMessage(PortfolioResultsMessage m)
        {
            if (!m.IsConversionComplete)
            {
                return;
            }

            if (_lastTotal != null && _lastTotal.Value.IsWithinPercentage(m.TotalConverted, 1))
            {
                return;
            }

            _lastTotal = m.TotalConverted;

            UiDispatcher.Invoke(() => UpdatePieChart(m));
        }
Ejemplo n.º 2
0
        private void UpdatePieChart(PortfolioResultsMessage m)
        {
            UiDispatcher.Invoke(() =>
            {
                lock (_lock)
                {
                    foreach (var i in m.NetworkItems.Where(x => x.ConvertedTotal != null))
                    {
                        var name = i.Network.Name;

                        var e = SeriesPieChartItems.FirstOrDefault(x => x.Title == name);

                        var seriesItem = new PieSeries
                        {
                            Title  = i.Network.Name,
                            Fill   = StringColor(name),
                            Values = new ChartValues <double>()
                            {
                                (double)i.ConvertedTotal.Value.ToDecimalValue()
                            },
                            DataLabels    = true,
                            LabelPosition = PieLabelPosition.InsideSlice,
                            Foreground    = (SolidColorBrush) new BrushConverter().ConvertFromString("#555"),
                            LabelPoint    = c => c.Participation > 0.05 ? $"{Math.Round(c.Participation, 2):P}" : null
                        };

                        if (e != null)
                        {
                            e.Values = new ChartValues <double>()
                            {
                                (double)i.ConvertedTotal.Value.ToDecimalValue()
                            }
                        }
                        ;
                        else
                        {
                            SeriesPieChartItems.Add(seriesItem);
                        }
                    }
                }
            }
                                );
        }