Beispiel #1
0
        public EditChartMenus(Chart2D chart2d, ComplexChart complexChart, Chart3DControl chart3DControl
#if !__MonoCS__
                              , System.Windows.Forms.Integration.ElementHost chart3DElementHost
#endif
                              )
        {
            InitializeComponent();

            charts = new Dictionary <CalculationsMode, IChart>
            {
                { CalculationsMode.Real, chart2d },
                { CalculationsMode.Complex, complexChart },
                { CalculationsMode.Fxy, chart3DControl }
            };
#if !__MonoCS__
            elementHostChart3d = chart3DElementHost;
#endif

            chart2d?.setupComboBoxes(typeOfChartComboBox, seriesOfChartComboBox, colorsOfChartComboBox,
                                     positionLegendComboBox, aligmentLegendComboBox);
            complexChart?.setupComboBoxes(countourLinesToolStripComboBox, colorAssignmentToolStripComboBox);

            if (charts.All(c => c.Value != null))
            {
                EventAggregator.Instance.Subscribe <CalculationsModeChangedEvent>(mode => SetMode(mode.CalculationsMode));
            }
        }
Beispiel #2
0
        public ChartingView(ChartAreaValuesView chartAreaValuesView, Chart2D chart2D, ComplexChart complexChart, Chart3DControl chart3D) : this()
        {
            chartAreaValuesView.Dock = DockStyle.Right;
            ChartAreaValuesView      = chartAreaValuesView;
            Chart2D      = chart2D;
            ComplexChart = complexChart;
            Chart3D      = chart3D;
            Charts       = new Dictionary <CalculationsMode, IChart>()
            {
                { CalculationsMode.Real, Chart2D },
                { CalculationsMode.Complex, ComplexChart },
                { CalculationsMode.Fxy, chart3D }
            };
#if !__MonoCS__
            var el = new System.Windows.Forms.Integration.ElementHost {
                Child = chart3D, Dock = DockStyle.Fill
            };
            chart3D.ParentControl = el;
#endif

            panel2.Controls.AddRange(new[]
            {
                chart2D,
                complexChart,
#if !__MonoCS__
                el,
#endif
                (Control)chartAreaValuesView,
            });
        }
        public void CreateMainChart(Song s, Chart2D chart)
        {
            var stat = (from m in SharedData.Database.AudioStatistic
                        join a in SharedData.Database.Artist on m.ArtistID equals a.ID
                        orderby s.Counter descending
                        select new { m.Artist.Name, m.TimeLineID, m.Counter });

            var groups = (from b in stat
                          join f in SharedData.Database.TimeLine on b.TimeLineID equals f.ID
                          select new { b.Name, f.Date, b.Counter }).Where(m => m.Name == s.Artist.Name);

            chart.DataCollection.RemoveAll();
            DataSeries series = new DataSeries(Color.LightGray, Color.Blue, Color.DimGray)
            {
                Thickness = 0.5f
            };

            int count        = groups.Count();
            var orderedGroup = groups.OrderBy(g => g.Date).ToList();

            series = new DataSeries(Color.LightGray, Color.Blue, Color.DimGray)
            {
                Thickness = 1f
            };

            int[] X = new int[count];
            int[] Y = new int[count];

            for (int h = 0; h < count; h++)
            {
                series.Name = orderedGroup[h].Name;

                Y[h] = h == 0 ? orderedGroup[h].Counter : Y[h - 1] + orderedGroup[h].Counter;
                X[h] = orderedGroup[h].Date.Day;

                series.AddPoint(new PointF(X[h], Y[h]));
            }

            for (int i = 1; i < X.Length; i++)
            {
                if (X[i] < X[i - 1])
                {
                    X = X.Skip(i).ToArray();
                    Y = Y.Skip(i).ToArray();
                    series.PointList.RemoveRange(0, i);
                    break;
                }
            }

            chart.DataCollection.Add(series);

            chart.Title.Text      = "Plot";
            chart.YAxis.LabelFont = new Font("Miramonte", 7f, FontStyle.Regular);
            chart.XAxis.LabelFont = new Font("Miramonte", 7f, FontStyle.Regular);
            chart.YAxis.Title     = "Plays";
            chart.XAxis.Title     = "Date";

            if (X.Length > 0)
            {
                if (X.Length == 1)
                {
                    chart.XAxis.Max = X.Max() + 1;
                    chart.XAxis.Min = X.Min() - 1;
                    chart.YAxis.Max = Y.Max() + 1;
                    chart.YAxis.Min = Y.Min() - 1;
                }
                else
                {
                    chart.XAxis.Max = X.Max();
                    chart.XAxis.Min = X.Min();
                    chart.YAxis.Max = Y.Max();
                    chart.YAxis.Min = Y.Min();
                }
            }
            else
            {
                chart.DataCollection.DataSeriesList[0].Name = s.Name;
            }

            chart.XAxis.Tick = 1;

            float y = chart.YAxis.Max;

            if (y < 40)
            {
                chart.YAxis.Tick = 2;
            }
            else if (y > 40 && y < 100)
            {
                chart.YAxis.Tick = 5;
            }
            else
            {
                chart.YAxis.Tick = 10;
            }


            chart.Legend.IsVisible = true;
            chart.Legend.Location  = Legend.Position.SouthEast;
        }
Beispiel #4
0
        private void wykres2DToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Chart2D form = new Chart2D();

            form.Show();
        }