Exemple #1
0
        public override void AddData(List <string> data, string varName, string title, string extra)
        {
            if (m_grid != null)
            {
                if (title == "columns")
                {
                    m_model.AddColumns(data);
                }
                else if (title == "item")
                {
                    m_model.AddPoint(data);
                }
            }
            else if (m_chart != null)
            {
                var collection = new ObservableCollection <DataPoint>();
                for (int i = 0; i < data.Count - 1; i += 2)
                {
                    string coord = data[i];
                    double value = Utils.ConvertToDouble(data[i + 1]);
                    collection.Add(new DataPoint(coord, value));
                }
                if (SfType == SyncFusionType.DOUGHNUT_GRAPH)
                {
                    SFDoughnutSeries doughnutSeries = new SFDoughnutSeries();
                    doughnutSeries.ItemsSource     = collection;
                    doughnutSeries.XBindingPath    = "XValue";
                    doughnutSeries.YBindingPath    = "YValue";
                    doughnutSeries.EnableTooltip   = true;
                    doughnutSeries.EnableAnimation = true;
                    if (!string.IsNullOrEmpty(title))
                    {
                        //doughnutSeries.Label = title;
                        m_chart.Title.Text = (NSString)title;
                    }
                    doughnutSeries.DataMarker.ShowLabel    = true;
                    doughnutSeries.DataMarker.LabelContent = title == "values" ? SFChartLabelContent.YValue :
                                                             SFChartLabelContent.Percentage;
                    doughnutSeries.DataMarkerPosition = SFChartCircularSeriesLabelPosition.OutsideExtended;
                    doughnutSeries.LegendIcon         = SFChartLegendIcon.Circle;
                    if (!string.IsNullOrEmpty(extra))
                    {
                        var angles = extra.Split(new char[] { ',', ':' });
                        doughnutSeries.StartAngle = Utils.ConvertToDouble(angles[0]);
                        if (angles.Length > 1)
                        {
                            doughnutSeries.EndAngle = Utils.ConvertToDouble(angles[1]);
                        }
                    }
                    m_chart.Series.Add(doughnutSeries);
                }
                else if (SfType == SyncFusionType.SPLINE_GRAPH)
                {
                    SFSplineSeries splineSeries = new SFSplineSeries();
                    splineSeries.ItemsSource             = collection;
                    splineSeries.XBindingPath            = "XValue";
                    splineSeries.YBindingPath            = "YValue";
                    splineSeries.EnableTooltip           = true;
                    splineSeries.EnableAnimation         = true;
                    splineSeries.Label                   = title;
                    splineSeries.DataMarker.MarkerHeight = 5;
                    splineSeries.DataMarker.MarkerWidth  = 5;
                    splineSeries.DataMarker.ShowMarker   = true;
                    splineSeries.LegendIcon              = SFChartLegendIcon.Rectangle;
                    if (!string.IsNullOrEmpty(extra))
                    {
                        var colors = extra.Split(new char[] { ',', ':' });
                        splineSeries.Color = UtilsiOS.String2Color(colors[0]);
                        if (colors.Length > 1)
                        {
                            var color = UtilsiOS.String2Color(colors[1]);
                            splineSeries.DataMarker.MarkerColor = color;
                        }
                    }
                    m_chart.Series.Add(splineSeries);
                }

                if (!string.IsNullOrEmpty(title))
                {
                    m_chart.Legend.Visible      = true;
                    m_chart.Legend.DockPosition = SFChartLegendPosition.Top;
                    //m_chart.Legend.
                    m_chart.Legend.ToggleSeriesVisibility = true;
                }
            }
            else if (m_picker != null)
            {
                m_strings            = data;
                m_picker.ItemsSource = data;
            }
        }