public ScaledPlotModel(double dpiXscale, double dpiYscale)
        {
            PlotMargins = new OxyThickness(PlotMargins.Left * dpiXscale,
                                           PlotMargins.Top * dpiYscale,
                                           PlotMargins.Right * dpiXscale,
                                           PlotMargins.Bottom * dpiYscale);

            Padding = new OxyThickness(Padding.Left * dpiXscale,
                                       Padding.Top * dpiYscale,
                                       Padding.Right * dpiXscale,
                                       Padding.Bottom * dpiYscale);

            TitlePadding *= dpiXscale;

            Legend legend = new();

            legend.LegendSymbolLength  *= dpiXscale;
            legend.LegendSymbolMargin  *= dpiXscale;
            legend.LegendPadding       *= dpiXscale;
            legend.LegendColumnSpacing *= dpiXscale;
            legend.LegendItemSpacing   *= dpiXscale;
            legend.LegendMargin        *= dpiXscale;

            Legends.Add(legend);
        }
Пример #2
0
        public void Reset()
        {
            Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString(GraphicsWindow.BackgroundColor));
            foreground = new SolidColorBrush((Color)ColorConverter.ConvertFromString(GraphicsWindow.PenColor));
            fontFamily = new FontFamily(GraphicsWindow.FontName);
            fontSize   = GraphicsWindow.FontSize;
            fontWeight = GraphicsWindow.FontBold ? FontWeights.Bold : FontWeights.Normal;
            fontStyle  = GraphicsWindow.FontItalic ? FontStyles.Italic : FontStyles.Normal;

            eStyle = Styles.PIE;
            Values = new List <double>();
            Labels = new List <string>();
            Count  = 0;

            eLegend           = Legends.LEGEND_PERCENT;
            bLegendBackground = false;
            legendScale       = 1.0;
            scale             = 1.0;

            hue           = 0;
            saturation    = 0.5;
            lightness     = 0.5;
            startColor    = 0;
            endColor      = 1;
            centralColour = "";
            eHSL          = HSL.HUE;

            Update();
        }
Пример #3
0
        /// <summary>
        /// Adds Statistics Denmark specific functionality for adding Legend.
        /// </summary>
        protected override void addLegend()
        {
            base.addLegend();

            if (showLegend)
            {
                Legends.First().Font        = Font.Small;
                Legends.First().ForeColor   = ColorTranslator.FromHtml("#4c4c4c");
                Legends.First().LegendStyle = LegendStyle.Table;

                if (!ChartTypes.Contains(SeriesChartType.Pie))
                {
                    Legends.First().TextWrapThreshold = 1000;
                }

                Legends.First().TableStyle = LegendTableStyle.Wide;

                if (!ChartTypes.Contains(SeriesChartType.Pie))
                {
                    float y = spaceUsedForTitle + space;
                    float h = legendHeight;
                    Legends.First().Position = new ElementPosition(0, y, 100, h);
                }
                else
                {
                    Legends.First().LegendStyle = LegendStyle.Column;
                    float top = spaceUsedForTitle + space + space;
                    Legends.First().Position = new ElementPosition(50, top, 50, 100 - top - SpaceUsedForInfoText);
                }
            }
        }
Пример #4
0
        private void MakeChart()
        {
            var chartArea = new ChartArea("Chart1");

            ChartAreas.Add(chartArea);
            Legends.Add("Chart1");

            if (graphicsSettings.ExactSolution)
            {
                MakeSeries(Algorithms.ExactSolution, "Chart1",
                           "Точное решение", this, paletteSettings.ExactSolution,
                           graphicsSettings.ExactSolutionBorderWidth);
            }
            if (graphicsSettings.DifferentialSweepMethod)
            {
                MakeSeries(Algorithms.DifferentialSweepMethod, "Chart1",
                           "Метод разностной прогонки", this, paletteSettings.DifferentialSweepMethod,
                           graphicsSettings.DifferentialSweepMethodBorderWidth);
            }
            if (graphicsSettings.ShootingMethod)
            {
                MakeSeries(Algorithms.ShootingMethod, "Chart1",
                           "Метод стрельбы", this, paletteSettings.ShootingMethod,
                           graphicsSettings.ShootingMethodBorderWidth);
            }
        }
Пример #5
0
        private void MakeChart()
        {
            var chartArea = new ChartArea("Chart1");

            ChartAreas.Add(chartArea);
            Legends.Add("Chart1");

            if (graphicsSettings.ExactSolution)
            {
                MakeSeries(Algorithms.ExactSolution, "Chart1",
                           "Точное решение", this, paletteSettings.ExactSolution,
                           graphicsSettings.ExactSolutionBorderWidth);
            }
            if (graphicsSettings.ExplicitEulerMethod)
            {
                MakeSeries(Algorithms.ExplicitEulerMethod, "Chart1",
                           "Явный метод Эйлера", this, paletteSettings.ExplicitEulerMethod,
                           graphicsSettings.ExplicitEulerMethodBorderWidth);
            }
            if (graphicsSettings.RungeKuttaMethod)
            {
                MakeSeries(Algorithms.RungeKuttaMethod, "Chart1",
                           "Метод Рунге-Кутта", this, paletteSettings.RungeKuttaMethod,
                           graphicsSettings.RungeKuttaMethodBorderWidth);
            }
            if (graphicsSettings.TrapeziumMethod)
            {
                MakeSeries(Algorithms.TrapeziumMethod, "Chart1",
                           "Метод трапеций", this, paletteSettings.TrapeziumMethod,
                           graphicsSettings.TrapeziumMethodBorderWidth);
            }
        }
Пример #6
0
 public void MakeGraphics()
 {
     ChartAreas.Clear();
     Series.Clear();
     Legends.Clear();
     MakeChart();
     Refresh();
 }
Пример #7
0
        /// <summary>
        /// Clear chart and add data from PXModel instance.
        /// </summary>
        /// <param name="px">PXModel to add to chart.</param>
        /// <param name="settings">Settings as PxChartSettings. Eg. as a Lambda expression.</param>
        public virtual void AddPxData(PXModel px, PxChartSettings settings)
        {
            Titles.Clear();
            Series.Clear();
            Legends.Clear();
            ChartAreas.Clear();

            initialize(px, settings);
        }
Пример #8
0
        private void button2_Click(object sender, EventArgs e)
        {
            int index = listView1.SelectedIndices[0];

            Legends.RemoveAt(index);
            Voices.RemoveAt(index);
            amount_voices -= 1;
            LoadLegends();
        }
Пример #9
0
 private void button3_Click(object sender, EventArgs e)
 {
     Legends.RemoveRange(0, Legends.Count);
     Voices.RemoveRange(0, Voices.Count);
     amount_voices = 0;
     LoadLegends();
     pictureBox1.BackColor = Color.FromArgb(240, 240, 240);
     mode          = 0;
     textBox1.Text = "Статистика:";
 }
Пример #10
0
        /// <summary>
        /// Adds Statistics Denmark specific functionality for adjusting the chart for displaying a populations pyramid.
        /// This method is in most cases called by PxMenu itself when needed.
        /// </summary>
        protected override void adjustForPopulationPyramid()
        {
            base.adjustForPopulationPyramid();

            if (showLegend)
            {
                ChartArea ca = ChartAreas.First();
                Legends.First().Position.X = ca.InnerPlotPosition.X + pixels(5);
            }
        }
Пример #11
0
        public virtual void Init <T1, TX1, TY1>(Data <T1, TX1, TY1> .Panel panel, Facet <T1> facet)
            where TX1 : struct
            where TY1 : struct
        {
            if (facet != null && panel.Data.Source.Equals(source))
            {
                this.facet = facet as Facet <T>;
            }

            legends = panel.Data.Legends;
        }
Пример #12
0
        protected virtual void ReadLegend(XmlTextReader xml)
        {
            //Int32 index = Convert.ToInt32(xml.GetAttribute("index"));

            iText.Kernel.Colors.DeviceRgb iTextColour = new DeviceRgb();
            ReadColour(xml, ref iTextColour, "colour");

            String label = xml.GetAttribute("label");

            Legends.Add(new Legend(label, iTextColour));
            mColours.Add(iTextColour);
        }
Пример #13
0
 /// <summary>
 /// Override in derived class to add legend.
 /// You might wanna include execution of the base method.
 /// </summary>
 protected virtual void addLegend()
 {
     if (showLegend)
     {
         Legends.Add(
             new Legend("Main")
         {
             Position        = new ElementPosition(0, 98 - legendHeight - SpaceUsedForInfoText, 100, legendHeight),
             LegendItemOrder = LegendItemOrder.ReversedSeriesOrder
         }
             );
     }
 }
Пример #14
0
 private void button1_Click(object sender, EventArgs e)
 {
     if (amount_voices >= 10)
     {
         MessageBox.Show("Превышено количество добавлений");
     }
     else
     {
         Legends.Add(textBox3.Text);
         Voices.Add(int.Parse(textBox2.Text));
         amount_voices++;
         LoadLegends();
     }
 }
Пример #15
0
            private void SetupLegend()
            {
                if (Series.Count <= 1)
                {
                    return;
                }

                var legend = new Legend();

                legend.LegendStyle = LegendStyle.Table;
                legend.TableStyle  = LegendTableStyle.Auto;
                legend.Docking     = Docking.Bottom;

                Legends.Add(legend);
            }
Пример #16
0
        /// <summary>
        /// Overridden to clone the inner objects.
        /// </summary>
        /// <returns>A deep clone of the <see cref="Map"/> field.</returns>
        public override object Clone()
        {
            // base.Clone() sets Font, which causes OnPropertyChanged,
            // which in turn disposes the clone's - i.e. OUR - image.
            // So we want to stop this bespredel:
            var tmpImage = _image;

            _image = null;
            Map clone = (Map)base.Clone();

            clone._c1mapper     = new C1Mapper(clone);
            clone.MarkerStyles  = (MarkerStyleCollection)MarkerStyles.Clone(clone);
            clone.LineStyles    = (LineStyleCollection)LineStyles.Clone(clone);
            clone.KmlItemStyles = (KmlItemStyleCollection)KmlItemStyles.Clone(clone);
            clone.Layers        = (LayerCollection)Layers.Clone(clone);
            clone.Legends       = (LegendCollection)Legends.Clone(clone);
            _image = tmpImage;
            return(clone);
        }
Пример #17
0
 public void LoadDataFile(String filename)
 {
     try
     {
         Legends.Clear();
         Columns.Clear();
         mColours.Clear();
         using (XmlTextReader reader = new XmlTextReader(filename))
         {
             while (reader.Read())
             {
                 switch (reader.NodeType)
                 {
                 case XmlNodeType.Element:
                     if (reader.Name == "column")
                     {
                         ReadColumn(reader);
                     }
                     else if (reader.Name == "legend")
                     {
                         ReadLegend(reader);
                     }
                     else if (reader.Name == "graph")
                     {
                         mFormatPercent = Convert.ToBoolean(reader.GetAttribute("format_percent"));
                         ValueLabel     = reader.GetAttribute("y_label");
                     }
                     else
                     {
                         MessageBox.Show("Wrong Graph Type", "Cannot Open", MessageBoxButtons.OK, MessageBoxIcon.Error);
                         return;
                     }
                     break;
                 }
             }
         }
     }
     catch
     {
         MessageBox.Show("Invalid Graph File", "Cannot Open", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Пример #18
0
        public ChartControl(List <Series> seriesList, string name) : base()
        {
            Name      = name;
            MaxPoints = 1000;

            title     = new Title(Name);
            ChartArea = new ChartArea("ChartArea");
            ChartArea.AxisX.Enabled             = AxisEnabled.False;
            ChartArea.AxisY.IsStartedFromZero   = false;
            ChartArea.AxisY.Enabled             = AxisEnabled.False;
            ChartArea.AxisY2.Enabled            = AxisEnabled.False;
            ChartArea.AxisX.LabelStyle.Enabled  = false;
            ChartArea.AxisY.LabelStyle.Enabled  = false;
            ChartArea.AxisY2.LabelStyle.Enabled = false;
            ChartArea.Position.X      = 0;
            ChartArea.Position.Y      = 40;
            ChartArea.Position.Height = 60;
            ChartArea.Position.Width  = 100;
            //chartArea.AxisY2.Title = "kVAR";
            //chartArea.AxisY.Title = "W";
            //chartArea.AxisY.LabelStyle.IsEndLabelVisible = true;

            Legends.Add(new Legend("LeftLegend")
            {
                Enabled     = false,
                LegendStyle = LegendStyle.Column,
            });
            Legends.Add(new Legend("RightLegend")
            {
                Enabled     = false,
                LegendStyle = LegendStyle.Column,
            });
            ChartAreas.Add(ChartArea);
            Titles.Add(title);
            if (seriesList != null)
            {
                foreach (Series series in seriesList)
                {
                    Series.Add(series);
                }
            }
        }
Пример #19
0
        /// <summary>
        /// Add legend
        /// </summary>
        protected override void addLegend()
        {
            if (showLegend)
            {
                LegendItemOrder order = LegendItemOrder.ReversedSeriesOrder;

                if ((ChartTypes.Length == 1) && (ChartTypes[0] == SeriesChartType.Pie))
                {
                    order = LegendItemOrder.SameAsSeriesOrder;
                }

                Legends.Add(
                    new Legend("Main")
                {
                    Position        = new ElementPosition(0, 98 - legendHeight - SpaceUsedForInfoText - 1, 100, legendHeight),
                    LegendItemOrder = order
                }
                    );
            }
        }
Пример #20
0
        public Legends_AllType GetAllLegends(string path)
        {
            Legends_AllType allType = new Legends_AllType();

            allType.legends_All = new List <Models.Legends>();
            Database DB = Sitecore.Context.Database;

            Sitecore.Data.Items.Item legendsItem = DB.GetItem(path);
            foreach (Sitecore.Data.Items.Item child in legendsItem.Children)
            {
                Legends legendInfoAll = new Legends();
                legendInfoAll.icon     = child.Fields[Templates.LegendInformation.LegendIcon];
                legendInfoAll.imageURL = Sitecore.Resources.Media.MediaManager.GetMediaUrl(legendInfoAll.icon.MediaItem);
                legendInfoAll.subtitle = child.Fields[Templates.LegendInformation.LegendSubtitle].ToString();

                allType.legends_All.Add(legendInfoAll);
            }

            return(allType);
        }
Пример #21
0
        protected override void Initialize()
        {
            ChartAreas.Add(new ChartArea("Distance"));
            Legends.Add(new Legend
            {
                LegendStyle = LegendStyle.Row,
                Alignment   = StringAlignment.Center,
                Docking     = Docking.Top
            });

            // prepare series
            Series.Add(new Series("Running")
            {
                XValueType = ChartValueType.Date,
                YValueType = ChartValueType.Double,
                ChartType  = SeriesChartType.StackedColumn,
                Color      = Color.RoyalBlue
            });
            Series.Add(new Series("Cycling")
            {
                XValueType = ChartValueType.Date,
                YValueType = ChartValueType.Double,
                ChartType  = SeriesChartType.StackedColumn,
                Color      = Color.Green,
            });

            // prepare axes
            var x = ChartAreas[0].AxisX;
            var y = ChartAreas[0].AxisY;

            // x
            x.IntervalAutoMode   = IntervalAutoMode.FixedCount;
            x.IntervalOffsetType = DateTimeIntervalType.Days;

            // y
            y.IntervalAutoMode  = IntervalAutoMode.VariableCount;
            y.LabelStyle.Format = "{0} km";
        }
Пример #22
0
        public FitnessGraph(Size size)
        {
            font = new Font("Microsoft Sans Serif", 8F, FontStyle.Regular, GraphicsUnit.Point, ((byte)(0)));

            CreateTitle();
            Size = size;

            BorderlineColor     = SystemColors.ControlDark;
            BorderlineDashStyle = ChartDashStyle.Solid;

            graph = CreateChart();
            ChartAreas.Add(graph);

            graphLegend = CreateLegend();
            Legends.Add(graphLegend);

            averageFitness = CreateAvgFitness();
            bestAgent      = CreateBestAgent();
            topAverage     = CreateTopAverage();
            Series.Add(averageFitness);
            Series.Add(topAverage);
            Series.Add(bestAgent);
        }
Пример #23
0
        private void GetLegends()
        {
            if (Legends == null)
            {
                Legends = GenerateLegends();
                return;
            }

            if (Items == null)
            {
                return;
            }

            // add missed legends
            Random rand = new Random(DateTime.Now.Millisecond);

            foreach (var item in Items)
            {
                var legendValue = item.GetType().GetProperty(LegendPropertyName).GetValue(item, null);

                var leg = from Legend lc in Legends where lc.LegendType.Equals(legendValue) select lc;
                if (leg.Count() == 0)
                {
                    Legend legend = new Legend();
                    legend.LegendType = legendValue;
                    Color c = Color.FromRgb(Convert.ToByte(rand.Next(256)), Convert.ToByte(rand.Next(256)), Convert.ToByte(rand.Next(256)));
                    legend.Brush = new SolidColorBrush(c);
                    Legends.Add(legend);
                }
            }

            // update event handlers
            foreach (var legend in Legends)
            {
                legend.IsVisibleChanged += (s, e) => Draw(false);
            }
        }
Пример #24
0
        private void Gestion_legend(Legend leg)
        {
            leg.Title              = "légende";
            leg.Name               = "legend";
            leg.BackColor          = Color.WhiteSmoke;
            leg.BackSecondaryColor = Color.White;
            leg.BackGradientStyle  = GradientStyle.DiagonalLeft;
            leg.BorderColor        = Color.Black;
            leg.BorderWidth        = 2;
            leg.TitleSeparator     = LegendSeparatorStyle.Line;
            leg.BorderDashStyle    = ChartDashStyle.Solid;
            leg.ShadowOffset       = 2;
            leg.Alignment          = StringAlignment.Center;
            leg.InsideChartArea    = "";
            leg.Docking            = Docking.Bottom;

            // Add header separator of type line
            leg.HeaderSeparator      = LegendSeparatorStyle.Line;
            leg.HeaderSeparatorColor = Color.Gray;

            // Add Color column
            LegendCellColumn firstColumn = new LegendCellColumn()
            {
                ColumnType      = LegendCellColumnType.SeriesSymbol,
                HeaderText      = "Color",
                HeaderBackColor = Color.WhiteSmoke
            };

            leg.CellColumns.Add(firstColumn);

            // Add Legend Text column
            LegendCellColumn secondColumn = new LegendCellColumn()
            {
                ColumnType      = LegendCellColumnType.Text,
                HeaderText      = "Name",
                Text            = "#LEGENDTEXT",
                HeaderBackColor = Color.WhiteSmoke
            };

            leg.CellColumns.Add(secondColumn);

            // Add AVG cell column
            LegendCellColumn avgColumn = new LegendCellColumn()
            {
                Text            = "#AVG{N2}",
                HeaderText      = "Avg",
                Name            = "AvgColumn",
                HeaderBackColor = Color.WhiteSmoke
            };

            leg.CellColumns.Add(avgColumn);

            // Add Max cell column
            LegendCellColumn maxColumn = new LegendCellColumn()
            {
                Text            = "#MAX{N1}",
                HeaderText      = "Max",
                Name            = "Maxcolumn",
                HeaderBackColor = Color.WhiteSmoke
            };

            leg.CellColumns.Add(maxColumn);

            // Set Min cell column attributes
            LegendCellColumn minColumn = new LegendCellColumn()
            {
                Text            = "#MIN{N1}",
                HeaderText      = "Min",
                Name            = "MinColumn",
                HeaderBackColor = Color.WhiteSmoke
            };

            leg.CellColumns.Add(minColumn);

            Legends.Add(leg);
        }
Пример #25
0
        protected override void Initialize()
        {
            ChartAreas.Add(new ChartArea("Biodata"));
            Legends.Add(new Legend
            {
                LegendStyle = LegendStyle.Row,
                Alignment   = StringAlignment.Center,
                Docking     = Docking.Top
            });

            // prepare series
            Series.Add(new Series("Resting Heart Rate")
            {
                XValueType  = ChartValueType.Date,
                YValueType  = ChartValueType.Int32,
                ChartType   = SeriesChartType.Spline,
                BorderWidth = 7,
                Color       = Color.RoyalBlue
            });
            Series.Add(new Series("Average Resting Heart Rate")
            {
                XValueType          = ChartValueType.Date,
                YValueType          = ChartValueType.Double,
                ChartType           = SeriesChartType.Spline,
                BorderWidth         = 1,
                Color               = Color.Turquoise,
                IsValueShownAsLabel = true
            });
            Series.Add(new Series("Local Average Resting Heart Rate")
            {
                XValueType  = ChartValueType.Date,
                YValueType  = ChartValueType.Double,
                ChartType   = SeriesChartType.Spline,
                BorderWidth = 3,
                Color       = Color.Purple
            });
            Series.Add(new Series("OwnIndex")
            {
                XValueType          = ChartValueType.Date,
                YValueType          = ChartValueType.Int32,
                ChartType           = SeriesChartType.Spline,
                IsValueShownAsLabel = true,
                BorderWidth         = 7,
                Color = Color.Green
            });
            Series.Add(new Series("Weight")
            {
                XValueType          = ChartValueType.Date,
                YValueType          = ChartValueType.Double,
                ChartType           = SeriesChartType.Spline,
                BorderWidth         = 7,
                Color               = Color.Red,
                IsValueShownAsLabel = true
            });
            Series.Add(new Series("Niggles")
            {
                XValueType  = ChartValueType.Date,
                YValueType  = ChartValueType.Int32,
                ChartType   = SeriesChartType.Point,
                MarkerSize  = 10,
                MarkerStyle = MarkerStyle.Cross,
                Color       = Color.DarkOrange
            });
            Series.Add(new Series("Notes")
            {
                XValueType  = ChartValueType.Date,
                YValueType  = ChartValueType.Int32,
                ChartType   = SeriesChartType.Point,
                MarkerSize  = 10,
                MarkerStyle = MarkerStyle.Square,
                Color       = Color.Yellow
            });

            // prepare axes
            var x = ChartAreas[0].AxisX;
            var y = ChartAreas[0].AxisY;

            // x
            x.IntervalAutoMode = IntervalAutoMode.FixedCount;
            x.IntervalType     = DateTimeIntervalType.Days;
            x.Interval         = 1;

            // y
            y.IntervalAutoMode = IntervalAutoMode.FixedCount;
            y.IntervalType     = DateTimeIntervalType.Number;
            y.Interval         = 5;
        }
Пример #26
0
        private void InitializeComponent()
        {
            var chartArea1 = this.ChartAreas.Add("ChartArea1");
            var legend1    = new Legend();
            var title1     = new Title();

            chartArea1.AxisX = new Axis(chartArea1, AxisName.X)
            {
                ArrowStyle              = AxisArrowStyle.Lines,
                Crossing                = 0D,
                InterlacedColor         = Color.White,
                IsLabelAutoFit          = false,
                LabelAutoFitMaxFontSize = 13,
                LabelStyle              = new LabelStyle()
                {
                    Font = new Font("Microsoft Sans Serif", 9F, FontStyle.Regular,
                                    GraphicsUnit.Point, 238)
                },
                LineWidth = 2,
                MajorGrid = new Grid()
                {
                    LineDashStyle = ChartDashStyle.Dash
                },
                MajorTickMark = new TickMark()
                {
                    Size          = 2F,
                    TickMarkStyle = TickMarkStyle.AcrossAxis
                },
                MinorGrid = new Grid()
                {
                    Enabled       = true,
                    LineColor     = Color.DarkGray,
                    LineDashStyle = ChartDashStyle.Dot
                },
                MinorTickMark = new TickMark()
                {
                    Enabled       = true,
                    TickMarkStyle = TickMarkStyle.AcrossAxis
                },
                Title          = "X",
                TitleAlignment = StringAlignment.Far,
                TitleFont      = new Font("Microsoft Sans Serif", 18F, FontStyle.Bold, GraphicsUnit.Point, 238)
            };

            chartArea1.AxisY = new Axis(chartArea1, AxisName.Y)
            {
                ArrowStyle              = AxisArrowStyle.Lines,
                Crossing                = 0D,
                InterlacedColor         = Color.White,
                IsLabelAutoFit          = false,
                LabelAutoFitMaxFontSize = 13,
                LabelStyle              = new LabelStyle()
                {
                    Font = new Font("Microsoft Sans Serif", 9F, FontStyle.Regular,
                                    GraphicsUnit.Point, 238)
                },
                LineWidth = 2,
                MajorGrid = new Grid()
                {
                    LineDashStyle = ChartDashStyle.Dash
                },
                MajorTickMark = new TickMark()
                {
                    Size          = 2F,
                    TickMarkStyle = TickMarkStyle.AcrossAxis
                },
                MinorGrid = new Grid()
                {
                    Enabled       = true,
                    LineColor     = Color.DarkGray,
                    LineDashStyle = ChartDashStyle.Dot
                },
                MinorTickMark = new TickMark()
                {
                    Enabled       = true,
                    TickMarkStyle = TickMarkStyle.AcrossAxis
                },
                TextOrientation = TextOrientation.Horizontal,
                Title           = "Y",
                TitleAlignment  = StringAlignment.Far,
                TitleFont       = new Font("Microsoft Sans Serif", 18F, FontStyle.Bold, GraphicsUnit.Point, 238)
            };

            //By default, if I select a rectangular area using the mouse, the chart will zoom to the selected area.
            //But this is quite annoying because it is prone to false operation
            chartArea1.CursorX = new System.Windows.Forms.DataVisualization.Charting.Cursor
            {
                IsUserEnabled          = false,
                IsUserSelectionEnabled = false
            };



            legend1.Font          = CustomFonts.GetMathFont(13.8F); //new Font("Cambria", 13.8F);
            legend1.IsTextAutoFit = false;
            legend1.Name          = "Legend1";

            Legends.Add(legend1);

            //this.N = 0D;
            Name        = "chart2d";
            title1.Font = new Font("Microsoft Sans Serif", 22.2F, FontStyle.Bold, GraphicsUnit.Point, 238);
            title1.Name = "Title1";
            Titles.Add(title1);
            Dock = DockStyle.Fill;


            ChartAreas[0].AxisX.ScaleView.MinSize = 0.1;
            ChartAreas[0].AxisY.ScaleView.MinSize = 0.1;


            Legends[0].Font = CustomFonts.GetMathFont(Legends[0].Font.Size);
            const float fontsize = 17.0F;

            Font = CustomFonts.GetMathFont(fontsize);
        }
 public void SetSource(IEnumerable <LegendAdornmentLayer> legendLayers) => Legends.Clear();
Пример #28
0
        public ChartTi()
        {
            BackColor = Supports.headGrey;
            ForeColor = Supports.textWhite;

            chartArea.AxisX.IntervalAutoMode  = IntervalAutoMode.VariableCount;
            chartArea.AxisX2.IntervalAutoMode = IntervalAutoMode.VariableCount;
            chartArea.AxisY.IntervalAutoMode  = IntervalAutoMode.VariableCount;
            chartArea.AxisY2.IntervalAutoMode = IntervalAutoMode.VariableCount;
            chartArea.Name = "chartArea";
            ChartAreas.Add(chartArea);

            chartArea.BackColor                      = Supports.headGrey;
            chartArea.AxisX.LineColor                = Supports.textBlack;
            chartArea.AxisY.LineColor                = Supports.textBlack;
            chartArea.AxisX.MajorGrid.LineColor      = Supports.textBlack;
            chartArea.AxisY.MajorGrid.LineColor      = Supports.textBlack;
            chartArea.AxisX.MajorGrid.LineDashStyle  = ChartDashStyle.Dash;
            chartArea.AxisX.IntervalType             = DateTimeIntervalType.Days;
            chartArea.AxisX.Interval                 = 1;
            chartArea.AxisX.ScaleView.Zoomable       = true;
            chartArea.CursorX.AutoScroll             = true;
            chartArea.CursorX.IsUserSelectionEnabled = true;
            chartArea.AxisX.LabelStyle.ForeColor     = Supports.textWhite;
            chartArea.AxisY.LabelStyle.ForeColor     = Supports.textWhite;
            chartArea.AxisY.MajorGrid.LineColor      = Supports.textBlack;
            chartArea.AxisX.InterlacedColor          = Supports.textBlack;
            chartArea.AxisY.InterlacedColor          = Supports.textBlack;
            chartArea.AxisX.TitleForeColor           = Supports.textWhite;
            chartArea.AxisY.TitleForeColor           = Supports.textWhite;
            chartArea.AxisX.LabelStyle.Format        = "dd.MM.yyyy";
            chartArea.AxisX.TitleFont                = new Font("Times New Roman", 15);
            chartArea.AxisY.TitleFont                = new Font("Times New Roman", 15);
            chartArea.AxisY.TextOrientation          = TextOrientation.Rotated270;

            Point?  prevPosition = null;
            ToolTip toolTip      = new ToolTip();

            MouseMove += (s, e) =>
            {
                var pos = e.Location;
                if (prevPosition.HasValue && pos == prevPosition.Value)
                {
                    return;
                }
                toolTip.RemoveAll();
                prevPosition = pos;
                var results = HitTest(pos.X, pos.Y, false, ChartElementType.DataPoint);

                foreach (var result in results)
                {
                    if (result.ChartElementType == ChartElementType.DataPoint)
                    {
                        var prop = result.Object as DataPoint;

                        if (prop != null)
                        {
                            var pointXPixel = result.ChartArea.AxisX.ValueToPixelPosition(prop.XValue);
                            var pointYPixel = result.ChartArea.AxisY.ValueToPixelPosition(prop.YValues[0]);

                            if (Math.Abs(pos.X - pointXPixel) < 4)
                            {
                                toolTip.Show("Время - " + DateTime.FromOADate(prop.XValue), this, pos.X, pos.Y);
                            }
                        }
                    }
                }
            };

            legend.BackColor      = Supports.headGrey;
            legend.ForeColor      = Supports.textWhite;
            legend.TitleForeColor = Supports.textWhite;

            legend.DockedToChartArea       = "chartArea";
            legend.Docking                 = Docking.Left;
            legend.IsDockedInsideChartArea = false;
            legend.LegendStyle             = LegendStyle.Column;
            legend.Name       = "Legend";
            legend.TableStyle = LegendTableStyle.Tall;
            legend.Title      = "Обозначения";
            Legends.Add(legend);
        }
Пример #29
0
        public void Reset()
        {
            Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString(GraphicsWindow.BackgroundColor));
            foreground = new SolidColorBrush((Color)ColorConverter.ConvertFromString(GraphicsWindow.PenColor));
            fontFamily = new FontFamily(GraphicsWindow.FontName);
            fontSize = GraphicsWindow.FontSize;
            fontWeight = GraphicsWindow.FontBold ? FontWeights.Bold : FontWeights.Normal;
            fontStyle = GraphicsWindow.FontItalic ? FontStyles.Italic : FontStyles.Normal;

            eStyle = Styles.PIE;
            Values = new List<double>();
            Labels = new List<string>();
            Count = 0;

            eLegend = Legends.LEGEND_PERCENT;
            bLegendBackground = false;
            legendScale = 1.0;
            scale = 1.0;

            hue = 0;
            saturation = 0.5;
            lightness = 0.5;
            startColor = 0;
            endColor = 1;
            centralColour = "";
            eHSL = HSL.HUE;

            Update();
        }
Пример #30
0
        /// <summary>
        /// Override in derived class to add change Population Pyramids.
        /// You might wanna include execution of the base class.
        /// </summary>
        protected virtual void adjustForPopulationPyramid()
        {
            SaveImage(Stream.Null, ChartImageFormat.Png);

            if (showLegend)
            {
                if (Series.First().Name.ToLower() == MaleValueNameForPopulationPyramid.ToLower())
                {
                    Legends.First().LegendItemOrder = LegendItemOrder.ReversedSeriesOrder;
                }
                else
                {
                    Legends.First().LegendItemOrder = LegendItemOrder.SameAsSeriesOrder;
                }
            }

            Axis axisX = ChartAreas["Main"].AxisX;

            //To show lowest age interval
            axisX.IntervalOffset = 1;

            if (AdjustAxes)
            {
                adjustAxis(axisX);
            }
            //axisX.SetIntervalForLabelsByPixels(pixelsForLabelX);

            Axis axisY = ChartAreas["Main"].AxisY;

            if (OverrideAxesSettings == null)
            {
                double max = Series.Max(x => x.Points.Max(p => Math.Abs(p.YValues.Max())));
                max           = max.FindMax();
                axisY.Minimum = max * -1;
                axisY.Maximum = max;

                axisY.SetIntervalForValuesByPixels(pixelsForLabelY);
            }
            else
            {
                if (OverrideAxesSettings != null)
                {
                    axisY = OverrideAxesSettings.ApplyTo(this, axisY);
                }
            }

            if (AdjustAxes)
            {
                adjustAxis(ChartAreas["Main"].AxisY);
            }

            axisY.Maximum = Math.Max(axisY.Minimum.AsAbs(), axisY.Maximum.AsAbs());
            axisY.Minimum = axisY.Maximum * -1;

            axisY.CustomLabels.Clear();
            for (double i = axisY.Maximum * -1; i <= axisY.Maximum; i += axisY.Interval)
            {
                axisY.CustomLabels.Add(
                    new CustomLabel()
                {
                    LabelMark    = LabelMarkStyle.SideMark,
                    Text         = Math.Abs(i).ToString(axisY.LabelStyle.Format),
                    FromPosition = i - axisY.Interval / 2,
                    ToPosition   = i + axisY.Interval / 2
                }
                    );
            }
        }
Пример #31
0
        private void Draw(bool updateLegends = true)
        {
            cnvMain.Children.Clear();

            double verticalLineHorizontalMargin = 40;
            double horisontalLineVerticalMargin = 25;
            double legendsHorizontalMargin      = 10;

            // Drawing Main lines
            var vLine = new Line
            {
                X1 = verticalLineHorizontalMargin,
                X2 = verticalLineHorizontalMargin,
                Y1 = 10,
                Y2 = cnvMain.ActualHeight - 10
            };

            var hLine = new Line
            {
                X1 = 10,
                X2 = cnvMain.ActualWidth - 10,
                Y1 = cnvMain.ActualHeight - horisontalLineVerticalMargin,
                Y2 = cnvMain.ActualHeight - horisontalLineVerticalMargin
            };

            cnvMain.Children.Add(vLine);
            cnvMain.Children.Add(hLine);

            //-------------------------------------------------------------------------------
            var tmpItems = new ArrayList();

            if (Items != null)
            {
                foreach (object item in Items)
                {
                    tmpItems.Add(item);
                }
            }

            if (tmpItems.Count == 0 ||
                String.IsNullOrEmpty(VerticalPropertyName) ||
                String.IsNullOrEmpty(HorizontalPropertyName) ||
                String.IsNullOrEmpty(LegendPropertyName))
            {
                return;
            }

            if (tmpItems[0].GetType().GetProperty(VerticalPropertyName) == null)
            {
                throw new ArgumentException("VerticalPropertyName is not correct.");
            }

            if (tmpItems[0].GetType().GetProperty(HorizontalPropertyName) == null)
            {
                throw new ArgumentException("HorizontalPropertyName is not correct.");
            }

            if (tmpItems[0].GetType().GetProperty(LegendPropertyName) == null)
            {
                throw new ArgumentException("LegendPropertyName is not correct.");
            }

            tmpItems.Sort(new ItemsComparer(HorizontalPropertyName));

            //-------------------------------------------------------------------------------

            var    horizontalValues = new List <double>();
            double maxValue         = 0;

            foreach (var item in tmpItems)
            {
                var verticalValue   = item.GetType().GetProperty(VerticalPropertyName).GetValue(item, null);
                var horizontalValue = item.GetType().GetProperty(HorizontalPropertyName).GetValue(item, null);

                if (!horizontalValues.Exists(i => i == Convert.ToDouble(horizontalValue)))
                {
                    horizontalValues.Add(Convert.ToDouble(horizontalValue));
                }

                if (Convert.ToDouble(verticalValue) > maxValue)
                {
                    maxValue = Convert.ToDouble(verticalValue);
                }
            }

            if (cnvMain.ActualWidth == 0)
            {
                return;
            }

            //-------------------------------------------------------------------------------

            double drawingAreaWidth  = (cnvMain.ActualWidth - verticalLineHorizontalMargin);
            double maxValueTopMargin = 10 + 20;

            var lMax = new Line
            {
                StrokeDashArray = new DoubleCollection()
                {
                    2
                },
                X1 = verticalLineHorizontalMargin - 5,
                X2 = hLine.X2,
                Y1 = maxValueTopMargin,
                Y2 = maxValueTopMargin
            };

            cnvMain.Children.Add(lMax);

            var lAvg = new Line
            {
                StrokeDashArray = new DoubleCollection()
                {
                    2
                },
                X1 = lMax.X1,
                X2 = lMax.X2,
                Y1 = (hLine.Y1 - lMax.Y1) / 2 + maxValueTopMargin,
                Y2 = (hLine.Y1 - lMax.Y1) / 2 + maxValueTopMargin
            };

            cnvMain.Children.Add(lAvg);

            var tbMax = new TextBlock {
                Text = maxValue.ToString()
            };

            var formattedMaxText = new FormattedText(tbMax.Text,
                                                     CultureInfo.CurrentUICulture,
                                                     FlowDirection.LeftToRight,
                                                     new Typeface(tbMax.FontFamily, tbMax.FontStyle, tbMax.FontWeight, tbMax.FontStretch),
                                                     tbMax.FontSize,
                                                     Brushes.Black);

            Canvas.SetLeft(tbMax, verticalLineHorizontalMargin - formattedMaxText.Width - 10);
            Canvas.SetTop(tbMax, lMax.Y1 - formattedMaxText.Height / 2.0);
            cnvMain.Children.Add(tbMax);

            var tbAvg = new TextBlock {
                Text = (maxValue / 2.0).ToString()
            };

            var formattedAvgText = new FormattedText(tbAvg.Text,
                                                     CultureInfo.CurrentUICulture,
                                                     FlowDirection.LeftToRight,
                                                     new Typeface(tbAvg.FontFamily, tbAvg.FontStyle, tbAvg.FontWeight, tbAvg.FontStretch),
                                                     tbAvg.FontSize,
                                                     Brushes.Black);

            Canvas.SetLeft(tbAvg, verticalLineHorizontalMargin - formattedAvgText.Width - 10);
            Canvas.SetTop(tbAvg, lAvg.Y1 - formattedAvgText.Height / 2.0);
            cnvMain.Children.Add(tbAvg);

            int    legendsCount = Legends.Count(f => f.IsVisible || !CanChangeLegendVisibility);
            double barsWidth    = (drawingAreaWidth - (horizontalValues.Count * legendsHorizontalMargin)) / horizontalValues.Count / legendsCount - legendsHorizontalMargin / 2.0;

            if (Double.IsInfinity(barsWidth) || Double.IsNaN(barsWidth))
            {
                barsWidth = 0;
            }

            double HorItemWidth = Math.Ceiling((drawingAreaWidth - (horizontalValues.Count * legendsHorizontalMargin)) / horizontalValues.Count);

            for (int i = 0; i < horizontalValues.Count; i++)
            {
                Line l = new Line();
                l.X1 = (HorItemWidth * i) + verticalLineHorizontalMargin + ((legendsCount * barsWidth) / 2.0) + legendsHorizontalMargin;
                l.X2 = l.X1;
                l.Y1 = hLine.Y1;
                l.Y2 = l.Y1 + 5;
                cnvMain.Children.Add(l);

                var tb = new TextBlock {
                    Text = horizontalValues[i].ToString()
                };

                var formattedText = new FormattedText(tb.Text,
                                                      CultureInfo.CurrentUICulture,
                                                      FlowDirection.LeftToRight,
                                                      new Typeface(tb.FontFamily, tb.FontStyle, tb.FontWeight, tb.FontStretch),
                                                      tb.FontSize,
                                                      Brushes.Black);

                Canvas.SetLeft(tb, l.X1 - (formattedText.Width / 2));
                Canvas.SetTop(tb, l.Y2 + 5);
                cnvMain.Children.Add(tb);
            }

            foreach (double horizontalIndex in horizontalValues)
            {
                var items = from object item in tmpItems
                            where Convert.ToDouble(item.GetType().GetProperty(HorizontalPropertyName).GetValue(item, null)) == horizontalIndex
                            orderby item.GetType().GetProperty(LegendPropertyName).GetValue(item, null)
                            select item;

                int legendValueIndex = 0;
                foreach (object item in items)
                {
                    var verticalValue   = item.GetType().GetProperty(VerticalPropertyName).GetValue(item, null);
                    var horizontalValue = item.GetType().GetProperty(HorizontalPropertyName).GetValue(item, null);
                    var legendValue     = item.GetType().GetProperty(LegendPropertyName).GetValue(item, null);

                    object currentLegend = null;
                    try
                    {
                        currentLegend = Legends.Where(i => i.LegendType.Equals(legendValue)).First();
                    }
                    catch
                    { }

                    if (currentLegend == null || (CanChangeLegendVisibility && !(currentLegend as Legend).IsVisible))
                    {
                        continue;
                    }

                    int horizontalValueIndex = horizontalValues.IndexOf(Convert.ToDouble(horizontalValue));

                    double barLeft = (HorItemWidth * horizontalValueIndex) + legendsHorizontalMargin +
                                     verticalLineHorizontalMargin +
                                     (legendValueIndex * barsWidth);

                    var b = new Border
                    {
                        Style      = (Style)cnvMain.FindResource("BarStyle"),
                        Width      = barsWidth,
                        Height     = Convert.ToDouble(verticalValue) * (hLine.Y1 - lMax.Y1) / maxValue,
                        Background = (currentLegend as Legend).Brush
                    };

                    Canvas.SetLeft(b, barLeft);
                    Canvas.SetTop(b, hLine.Y1 - b.Height);
                    cnvMain.Children.Add(b);

                    var tbValue = new TextBlock();
                    Panel.SetZIndex(tbValue, 100);
                    tbValue.Text = verticalValue.ToString();

                    var binding = new Binding("ValueVisibility")
                    {
                        Source = this
                    };
                    tbValue.SetBinding(TextBlock.VisibilityProperty, binding);

                    var formattedText = new FormattedText(tbValue.Text,
                                                          CultureInfo.CurrentUICulture,
                                                          FlowDirection.LeftToRight,
                                                          new Typeface(tbValue.FontFamily, tbValue.FontStyle, tbValue.FontWeight, tbValue.FontStretch),
                                                          tbValue.FontSize,
                                                          Brushes.Black);

                    Canvas.SetLeft(tbValue, barLeft + (((barLeft + barsWidth) - barLeft) / 2 - formattedText.Width / 2));
                    Canvas.SetTop(tbValue, hLine.Y1 - b.Height - formattedText.Height - 5);
                    cnvMain.Children.Add(tbValue);

                    legendValueIndex++;
                }
            }

            if (updateLegends)
            {
                DrawLegends();
            }
            else
            {
                cnvMain.Children.Add(brdLegends);
            }
        }