Esempio n. 1
0
        /// <summary>
        /// create chart legend style
        /// </summary>
        /// <param name="nodeStyle"></param>
        /// <returns></returns>

        public LegendStyle CreateChartLegendStyle(XmlNode nodeStyle)
        {
            LegendStyle legendStyle = new LegendStyle(this.Chart.Document);

            legendStyle.Node = nodeStyle;

            IPropertyCollection pCollection = new IPropertyCollection();

            if (nodeStyle.HasChildNodes)
            {
                foreach (XmlNode nodeChild in nodeStyle.ChildNodes)
                {
                    IProperty property = this.GetProperty(legendStyle, nodeChild);
                    if (property != null)
                    {
                        pCollection.Add(property);
                    }
                }
            }

            legendStyle.Node.InnerXml = "";

            foreach (IProperty property in pCollection)
            {
                legendStyle.PropertyCollection.Add(property);
            }

            //this.Chart .Styles .Add (legendStyle);

            return(legendStyle);
        }
Esempio n. 2
0
        protected override void OnPaint(PaintEventArgs e)
        {
            LegendStyle style = _legend_theme.GetStyle(ThemeMode) as LegendStyle;

            Model.LegendBorder    = Helper.ConvertColorToOxyColor(style.BorderColor);
            Model.LegendTextColor = Helper.ConvertColorToOxyColor(style.LabelColor);
            Model.TitleColor      = Helper.ConvertColorToOxyColor(style.TitleColor);
            Color back_color = Helper.GetBackColorByThemeMode(ThemeMode);


            _back_brush.Color = back_color;
            e.Graphics.FillRectangle(_back_brush, this.Bounds);
            for (int i = 0; i < this.Model.Series.Count - 1; i++)
            {
                ISeries pre = this.Model.Series[i] as ISeries;
                for (int j = i + 1; j < this.Model.Series.Count; j++)
                {
                    ISeries cur = this.Model.Series[j] as ISeries;
                    if (pre.Priority > cur.Priority)
                    {
                        Series temp = this.Model.Series[i];
                        this.Model.Series[i] = this.Model.Series[j];
                        this.Model.Series[j] = temp;
                    }
                }
            }

#if DEBUG_MAP
            Console.WriteLine("onpaint");
#endif
            base.OnPaint(e);
        }
Esempio n. 3
0
        /// <summary>
        /// create chart legend style
        /// </summary>
        /// <param name="nodeStyle"></param>
        /// <returns></returns>
        public LegendStyle CreateChartLegendStyle(XElement nodeStyle)
        {
            LegendStyle legendStyle = new LegendStyle(Chart.Document)
            {
                Node = nodeStyle
            };

            IPropertyCollection pCollection = new IPropertyCollection();

            if (nodeStyle.HasElements)
            {
                foreach (XElement nodeChild in nodeStyle.Elements())
                {
                    IProperty property = GetProperty(legendStyle, nodeChild);
                    if (property != null)
                    {
                        pCollection.Add(property);
                    }
                }
            }

            legendStyle.Node.Value = "";

            foreach (IProperty property in pCollection)
            {
                legendStyle.PropertyCollection.Add(property);
            }

            //this.Chart .Styles .Add (legendStyle);

            return(legendStyle);
        }
Esempio n. 4
0
        public ChartLegend(Chart chart)
        {
            Chart       = chart;
            Document    = chart.Document;
            Node        = new XElement(Ns.Chart + "legend");
            LegendStyle = new LegendStyle(chart.Document);

            chart.Content.Add(this);
        }
Esempio n. 5
0
        public static void AddLegend(Chart chart, LegendStyle style)
        {
            var legend = new Legend();
            legend.Enabled = true;
            legend.LegendStyle = style;
            legend.Name = "MyLegend";
            legend.Position.Auto = true;

            chart.Legends.Add(legend);
        }
        private void ControlChange(object sender, System.EventArgs e)
        {
            if (InsideCheck.Checked)
            {
                Chart1.Legends["Default"].InsideChartArea = "Default";
            }
            else
            {
                Chart1.Legends["Default"].InsideChartArea = "";
            }

            Chart1.Legends["Default"].Enabled = !DisableCheck.Checked;

            if (this.TheStyle.SelectedItem.ToString() == "Table" && !this.DisableCheck.Checked)
            {
                this.TheTableStyle.Enabled = true;
            }

            else
            {
                this.TheTableStyle.Enabled = false;
            }

            if (this.TheTableStyle.SelectedIndex >= 0)
            {
                Chart1.Legends["Default"].TableStyle = (LegendTableStyle)LegendTableStyle.Parse(typeof(LegendTableStyle), this.TheTableStyle.SelectedItem.ToString());
            }

            if (this.TheStyle.SelectedIndex >= 0)
            {
                Chart1.Legends["Default"].LegendStyle = (LegendStyle)LegendStyle.Parse(typeof(LegendStyle), this.TheStyle.SelectedItem.ToString());
            }

            if (this.TheDocking.SelectedIndex >= 0)
            {
                Chart1.Legends["Default"].Docking = (Docking)Docking.Parse(typeof(Docking), this.TheDocking.SelectedItem.ToString());
            }

            if (this.TheAlignment.SelectedIndex >= 0)
            {
                Chart1.Legends["Default"].Alignment = (StringAlignment)StringAlignment.Parse(typeof(StringAlignment), this.TheAlignment.SelectedItem.ToString());
            }

            if (this.cb_Reversed.Checked)
            {
                Chart1.Legends["Default"].LegendItemOrder = LegendItemOrder.ReversedSeriesOrder;
            }

            else
            {
                Chart1.Legends["Default"].LegendItemOrder = LegendItemOrder.SameAsSeriesOrder;
            }
        }
Esempio n. 7
0
        public ChartLegend(Chart chart, string styleName)
        {
            Chart    = chart;
            Document = chart.Document;
            Node     = new XElement(Ns.Chart + "legend");
            XAttribute xa = new XAttribute(Ns.Chart + "style-name", styleName);

            Node.Add(xa);
            LegendStyle = new LegendStyle(Document, styleName);
            Chart.Styles.Add(LegendStyle);

            chart.Content.Add(this);
        }
Esempio n. 8
0
        /// <summary>
        ///     Legend Style
        /// </summary>
        /// <param name="Colors">List of colors for each rectangle.</param>
        /// <param name="Address">Grid Coordinates.</param>
        /// <param name="Width">Width in pixels.</param>
        /// <param name="Height">Height in pixels.</param>
        /// <param name="Title">Title below legend.</param>
        /// <param name="RectangleSize">Rectangle size in pixels.</param>
        /// <returns name="Style">Style</returns>
        public static LegendStyle Style(
            [DefaultArgumentAttribute("Charts.MiscNodes.GetNull()")] List <DSCore.Color> Colors,
            [DefaultArgument("Charts.MiscNodes.GetNull()")] GridAddress Address,
            int Width         = 200,
            int Height        = 400,
            string Title      = "Title",
            int RectangleSize = 20
            )
        {
            LegendStyle style = new LegendStyle();

            style.Width         = Width;
            style.Height        = Height;
            style.Title         = Title;
            style.RectangleSize = RectangleSize;

            if (Colors != null)
            {
                List <string> hexColors = new List <string>();
                foreach (DSCore.Color color in Colors)
                {
                    string col = ChartsUtilities.ColorToHexString(sColor.FromArgb(color.Alpha, color.Red, color.Green, color.Blue));
                    hexColors.Add(col);
                }
                style.Colors = hexColors;
            }
            else
            {
                style.Colors = null;
            }

            if (Address != null)
            {
                style.GridRow    = Address.X;
                style.GridColumn = Address.Y;
            }
            else
            {
                style.GridRow    = 1;
                style.GridColumn = 1;
            }

            return(style);
        }
Esempio n. 9
0
        public static LegendStyle GetLegendTypeByStr(string legendTypeStr)
        {
            LegendStyle resultvalue = LegendStyle.SymbolStyle;
            string      resultstr   = legendTypeStr.Trim();

            if (resultstr.Equals("s") || resultstr.Equals("S"))
            {
                resultvalue = LegendStyle.SymbolStyle;
            }
            else if (resultstr.Equals("t") || resultstr.Equals("T"))
            {
                resultvalue = LegendStyle.YSTxtStyle;
            }
            else
            {
                resultvalue = LegendStyle.SymbolStyle;
            }
            return(resultvalue);
        }
Esempio n. 10
0
        /// <summary>
        ///     Legend Style
        /// </summary>
        /// <param name="Colors">List of colors for each rectangle.</param>
        /// <param name="Address">Grid Coordinates.</param>
        /// <param name="Width">Width in pixels.</param>
        /// <param name="Height">Height in pixels.</param>
        /// <param name="Title">Title below legend.</param>
        /// <param name="RectangleSize">Rectangle size in pixels.</param>
        /// <returns name="Style">Style</returns>
        public static LegendStyle Style(
            [DefaultArgumentAttribute("Charts.MiscNodes.GetNull()")] List <DSCore.Color> Colors,
            [DefaultArgument("Charts.MiscNodes.GetNull()")] GridAddress Address,
            int Width         = 200,
            int Height        = 400,
            string Title      = "Title",
            int RectangleSize = 20
            )
        {
            LegendStyle style = new LegendStyle();

            style.Width         = Width;
            style.Height        = Height;
            style.Title         = Title;
            style.RectangleSize = RectangleSize;
            style.SizeX         = (int)Math.Ceiling(Width / 100d);
            style.SizeY         = (int)Math.Ceiling(Height / 100d);

            if (Colors != null)
            {
                List <string> hexColors = Colors.Select(x => ChartsUtilities.ColorToHexString(sColor.FromArgb(x.Alpha, x.Red, x.Green, x.Blue))).ToList();
                style.Colors = new JavaScriptSerializer().Serialize(hexColors);
            }
            else
            {
                style.Colors = null;
            }

            if (Address != null)
            {
                style.GridRow    = Address.X;
                style.GridColumn = Address.Y;
            }
            else
            {
                style.GridRow    = 1;
                style.GridColumn = 1;
            }

            return(style);
        }
Esempio n. 11
0
        private void SetupChart()
        {
            // Set legend style
            Chart1.Legends["Default"].LegendStyle = (LegendStyle)LegendStyle.Parse(typeof(LegendStyle), LegendStyleList.SelectedItem.Text);

            // Set legend docking
            Chart1.Legends["Default"].Docking = (Docking)Docking.Parse(typeof(Docking), LegendDockingList.SelectedItem.Text);

            // Set legend alignment
            Chart1.Legends["Default"].Alignment = (StringAlignment)StringAlignment.Parse(typeof(StringAlignment), LegendAlinmentList.SelectedItem.Text);

            // Set whether the legend is reversed
            if (this.Reversed.Checked)
            {
                Chart1.Legends["Default"].LegendItemOrder = LegendItemOrder.ReversedSeriesOrder;
            }

            else
            {
                Chart1.Legends["Default"].LegendItemOrder = LegendItemOrder.SameAsSeriesOrder;
            }

            // Display legend in the "Default" chart area
            if (InsideChartArea.Checked)
            {
                Chart1.Legends["Default"].InsideChartArea = "ChartArea1";
            }

            // Set table style
            this.Chart1.Legends["Default"].TableStyle = (LegendTableStyle)LegendTableStyle.Parse(typeof(LegendTableStyle), this.TheTableStyle.SelectedItem.ToString());

            if (this.LegendStyleList.SelectedItem.ToString() == "Table" && !this.LegendDisabled.Checked)
            {
                this.TheTableStyle.Enabled = true;
            }

            else
            {
                this.TheTableStyle.Enabled = false;
            }
        }
Esempio n. 12
0
 /// <summary>
 ///     Legend
 /// </summary>
 /// <param name="Data">Legend Data</param>
 /// <param name="Style">Legend Style</param>
 /// <returns name="legend">Legend object.</returns>
 public static D3jsLib.Legend.Legend Create(LegendData Data, LegendStyle Style)
 {
     D3jsLib.Legend.Legend chart = new D3jsLib.Legend.Legend(Data, Style);
     return(chart);
 }
Esempio n. 13
0
 internal void ApplyTheme(LegendStyle themeConfiguration)
 {
     itemHiddenStyle.CopyStyles(themeConfiguration.hiddenStyle);
     itemHoverStyle.CopyStyles(themeConfiguration.hoverStyle);
     itemStyle.CopyStyles(themeConfiguration.style);
 }
Esempio n. 14
0
 public static ICanvasImage CreateLegend(ICanvasResourceCreator resourceCreator, LegendStyle style,
                                         List <string> serieLabels, List <Color> colorSpace,
                                         LegendPosition legendPosition)
 {
     if (serieLabels?.Count > 0 && colorSpace?.Count >= serieLabels.Count)
     {
         var commandList = new CanvasCommandList(resourceCreator);
         using (var drawSession = commandList.CreateDrawingSession())
         {
             var cancasTextArray =
                 serieLabels.Select(o => CreateCanvasText(resourceCreator, o, style.LabelFormat)).ToArray();
             var textRectHeight    = cancasTextArray.Select(o => o.DrawBounds.Height).Max();
             var groupHeight       = (float)Math.Max(textRectHeight, style.ColorBlockHeight);
             var colorBlockYOffset = (float)(textRectHeight - style.ColorBlockHeight) / 2;
             var startXOffset      = 0f;
             var startYOffset      = colorBlockYOffset;
             for (int i = 0; i < serieLabels.Count; i++)
             {
                 drawSession.FillRectangle(startXOffset, startYOffset, style.ColorBlockWidth,
                                           style.ColorBlockHeight, colorSpace[i]);
                 drawSession.DrawTextLayout(cancasTextArray[i],
                                            startXOffset + style.ColorBlockWidth + style.LabelFormat.Thickness.Left,
                                            startYOffset - colorBlockYOffset - (float)cancasTextArray[i].DrawBounds.Y,
                                            ColorConverter.ConvertHexToColor(style.LabelFormat.Foreground));
                 if (legendPosition == LegendPosition.Bottom)
                 {
                     startXOffset += style.ColorBlockWidth;
                     startXOffset += style.LabelFormat.Thickness.Left;
                     startXOffset += (float)cancasTextArray[i].LayoutBounds.Width;
                     startXOffset += style.LabelFormat.Thickness.Right;
                 }
                 else if (legendPosition == LegendPosition.Right)
                 {
                     startYOffset += groupHeight;
                     startYOffset += style.LabelFormat.Thickness.Bottom;
                 }
                 cancasTextArray[i].Dispose();
             }
         }
         return(commandList);
     }
     return(null);
 }