Esempio n. 1
0
        private void PlotChart(ChartDisplay cd)
        {
            var primXResults = new List <double[]>();
            var primYResults = new List <double[]>();
            var secXResults  = new List <double[]>();
            var secYResults  = new List <double[]>();

            if (cd.PrimaryX != null && cd.PrimaryX.Item1 != null)
            {
                primXResults = GetRelevantData(cd.PrimaryX.Item1, cd.PrimaryX.Item2);
            }

            if (cd.PrimaryY != null && cd.PrimaryY.Item1 != null)
            {
                primYResults = GetRelevantData(cd.PrimaryY.Item1, cd.PrimaryY.Item2);
            }

            if (cd.SecondaryY != null && cd.SecondaryY.Item1 != null)
            {
                secYResults = GetRelevantData(cd.SecondaryY.Item1, cd.SecondaryY.Item2);
            }

            if (primXResults.Count > 0 && (primYResults.Count > 0 || secYResults.Count > 0))
            {
                cd.c.Series.Clear();
                cd.c.ChartAreas[0].AxisX.Title = ((LabelAttribute)cd.PrimaryX.Item1.GetCustomAttributes(typeof(LabelAttribute), false)[0]).Label;
                if (primYResults.Count > 0)
                {
                    cd.c.ChartAreas[0].AxisY.Title = ((LabelAttribute)cd.PrimaryY.Item1.GetCustomAttributes(typeof(LabelAttribute), false)[0]).Label;
                }
                else if (secYResults.Count > 0)
                {
                    cd.c.ChartAreas[0].AxisY.Title = ((LabelAttribute)cd.SecondaryY.Item1.GetCustomAttributes(typeof(LabelAttribute), false)[0]).Label;
                }

                if (primYResults.Count > 0 && secYResults.Count > 0)
                {
                    cd.c.ChartAreas[0].AxisY2.Title = ((LabelAttribute)cd.SecondaryY.Item1.GetCustomAttributes(typeof(LabelAttribute), false)[0]).Label;
                }

                for (int i = 0; i < Math.Min(primYResults.Count, primXResults.Count); i++)
                {
                    PlotSpline(cd.c, primXResults[i], primYResults[i], cd.c.ChartAreas[0].AxisY.Title, Color.Blue, i == 0, true);
                }

                //if we are suing the same X-axis for both Y-graphs
                if (secXResults.Count == 0)
                {
                    for (int i = 0; i < Math.Min(secYResults.Count, primXResults.Count); i++)
                    {
                        PlotSpline(cd.c, primXResults[i], secYResults[i], cd.c.ChartAreas[0].AxisY.Title, Color.Blue, i == 0, true);
                    }
                }

                SetAxis(cd.c);
            }
        }
Esempio n. 2
0
        static void Main(string[] args)
        {
            AbstractChart chart        = new PieChart();
            ChartDisplay  chartDisplay = new ChartDisplay();

            chartDisplay.SetChart(chart);
            chartDisplay.Display();

            // Console.ReadLine();
        }
Esempio n. 3
0
        private async void ChooseGraphType(object sender, EventArgs args)
        {
            var chartTypes = EnumUtil.GetValues <ChartType>().ToArray();

            string[] list = new string[chartTypes.Count()];
            for (var i = 0; i < chartTypes.Count(); i++)
            {
                list[i] = ChartDisplay.Get(chartTypes[i]);
            }

            var result = await DisplayActionSheet("Choose Graph", TextResources.Cancel, null, list);

            if (result != null)
            {
                if (result != TextResources.Cancel)
                {
                    _model.SetChart((ChartType)Enum.Parse(typeof(ChartType), result.Replace(" ", "")));
                }
            }
        }
Esempio n. 4
0
        private void PlotChart(ChartDisplay cd)
        {
            var primXResults = new List<double[]>();
            var primYResults = new List<double[]>();
            var secXResults = new List<double[]>();
            var secYResults = new List<double[]>();

            if (cd.PrimaryX != null && cd.PrimaryX.Item1 != null)
                primXResults = GetRelevantData(cd.PrimaryX.Item1, cd.PrimaryX.Item2);

            if (cd.PrimaryY != null && cd.PrimaryY.Item1 != null)
                primYResults = GetRelevantData(cd.PrimaryY.Item1, cd.PrimaryY.Item2);

            if (cd.SecondaryY != null && cd.SecondaryY.Item1 != null)
                secYResults = GetRelevantData(cd.SecondaryY.Item1, cd.SecondaryY.Item2);

            if (primXResults.Count > 0 && (primYResults.Count > 0 || secYResults.Count > 0))
            {
                cd.c.Series.Clear();
                cd.c.ChartAreas[0].AxisX.Title = ((LabelAttribute)cd.PrimaryX.Item1.GetCustomAttributes(typeof(LabelAttribute), false)[0]).Label;
                if (primYResults.Count > 0)
                    cd.c.ChartAreas[0].AxisY.Title = ((LabelAttribute)cd.PrimaryY.Item1.GetCustomAttributes(typeof(LabelAttribute), false)[0]).Label;
                else if (secYResults.Count > 0)
                    cd.c.ChartAreas[0].AxisY.Title = ((LabelAttribute)cd.SecondaryY.Item1.GetCustomAttributes(typeof(LabelAttribute), false)[0]).Label;

                if (primYResults.Count > 0 && secYResults.Count > 0)
                    cd.c.ChartAreas[0].AxisY2.Title = ((LabelAttribute)cd.SecondaryY.Item1.GetCustomAttributes(typeof(LabelAttribute), false)[0]).Label;

                for (int i = 0; i < Math.Min(primYResults.Count, primXResults.Count); i++)
                    PlotSpline(cd.c, primXResults[i], primYResults[i], cd.c.ChartAreas[0].AxisY.Title, Color.Blue, i == 0, true);

                //if we are suing the same X-axis for both Y-graphs
                if (secXResults.Count == 0)
                    for (int i = 0; i < Math.Min(secYResults.Count, primXResults.Count); i++)
                        PlotSpline(cd.c, primXResults[i], secYResults[i], cd.c.ChartAreas[0].AxisY.Title, Color.Blue, i == 0, true);

                SetAxis(cd.c);
            }
        }
Esempio n. 5
0
 public BaseChart(string title)
 {
     Chart   = new C();
     Display = new ChartDisplay(Chart, title);
     SetupChart();
 }