Example #1
0
        private void ExportSVGButton_Click(object sender, EventArgs e)
        {
            string path = Application.StartupPath + "\\ChartExport.svg";

            NSvgImageFormat fmt = new NSvgImageFormat();

            nChartControl1.ImageExporter.SaveToFile(path, fmt);

            Process.Start(path);
        }
Example #2
0
        protected void Page_Load(object sender, System.EventArgs e)
        {
            // start document initialization
            Document = NDrawingView1.Document;
            Document.BeginInit();

            Document.Width  = NDrawingView1.Dimensions.Width;
            Document.Height = NDrawingView1.Dimensions.Height;

            XmlDocument xmlDocument = new XmlDocument();

            xmlDocument.Load(this.MapPathSecure(this.TemplateSourceDirectory + "\\MapOfUSA.xml"));

            XmlElement map = (XmlElement)xmlDocument.ChildNodes[0];

            Color[] stateColorTable = new Color[6];

            stateColorTable[0] = Color.LightPink;
            stateColorTable[1] = Color.Bisque;
            stateColorTable[2] = Color.Moccasin;
            stateColorTable[3] = Color.MistyRose;
            stateColorTable[4] = Color.PowderBlue;
            stateColorTable[5] = Color.Ivory;

            int   stateCounter       = 0;
            Color stateHighlighColor = Color.Orange;

            foreach (XmlElement state in map.ChildNodes)
            {
                string stateId = state.Attributes["Id"].Value.ToString();

                NCompositeShape stateShape = CreateState(state);
                // add to active layer
                Document.ActiveLayer.AddChild(stateShape);

//				NRotatedBoundsLabel label = new NRotatedBoundsLabel("Click to go to :" + stateId + " webpage", stateShape.UniqueId, new Nevron.Diagram.NMargins());
//				stateShape.Labels.AddChild(label);

                // set fill and stroke styles
                Color stateColor = stateColorTable[stateCounter % 6];

                stateShape.Style.FillStyle   = new NColorFillStyle(stateColor);
                stateShape.Style.StrokeStyle = new NStrokeStyle(1, Color.Black);

                NInteractivityStyle interactivityStyle = new NInteractivityStyle();
                stateShape.Style.InteractivityStyle = interactivityStyle;

                string elementId   = new NElementIdentifier(((INElement)stateShape.Primitives.GetChildAt(0)).Id).ToString();
                string stateScript = "onmouseover = 'HighlightState(\"" + elementId + "\", \"" + ColorToSVG(stateHighlighColor) + "\")' onmouseout = 'HighlightState(\"" + elementId + "\", \"" + ColorToSVG(stateColor) + "\")'";
                interactivityStyle.CustomMapAreaAttribute.JScriptAttribute = stateScript;
                interactivityStyle.UrlLink.Url             = "http://worldatlas.com/webimage/countrys/namerica/usstates/" + stateId.ToString() + ".htm";
                interactivityStyle.UrlLink.OpenInNewWindow = true;

                NElementIdentifier identifier = new NElementIdentifier(stateShape.Id);
                stateCounter++;
            }

            Document.BackgroundStyle.FillStyle = new NGradientFillStyle(GradientStyle.Horizontal, GradientVariant.Variant1, Color.LightSeaGreen, Color.LightBlue);

            // change the response type to SVG
            NImageResponse response = new NImageResponse();

            NSvgImageFormat svgImageFormat = new NSvgImageFormat();

            svgImageFormat.EnableInteractivity = true;
            svgImageFormat.CustomScript        = GetScript();

            Hashtable attributes = new Hashtable();

            attributes["onload"]      = "Initialize(evt)";
            svgImageFormat.Attributes = attributes;
            response.ImageFormat      = svgImageFormat;

            NDrawingView1.ServerSettings.BrowserResponseSettings.DefaultResponse = response;
        }
Example #3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
            }

            nChartControl1.BackgroundStyle.FrameStyle.Visible = false;

            NChart chart = nChartControl1.Charts[0];

            chart.Width      = 100;
            chart.Height     = 60;
            chart.BoundsMode = BoundsMode.Fit;
            chart.Location   = new NPointL(
                new NLength(10, NRelativeUnit.ParentPercentage),
                new NLength(20, NRelativeUnit.ParentPercentage));
            chart.Size = new NSizeL(
                new NLength(80, NRelativeUnit.ParentPercentage),
                new NLength(70, NRelativeUnit.ParentPercentage));


            chart.Axis(StandardAxis.Depth).Visible = false;
            chart.Wall(ChartWallType.Back).Visible = false;

            m_Line1      = (NLineSeries)chart.Series.Add(SeriesType.Line);
            m_Line1.Name = "Line 1";
            m_Line1.DataLabelStyle.Visible = false;
            m_Line1.BorderStyle.Color      = Color.DodgerBlue;
            m_Line1.FillStyle                     = new NColorFillStyle(Color.DodgerBlue);
            m_Line1.MarkerStyle.FillStyle         = new NColorFillStyle(Color.DodgerBlue);
            m_Line1.MarkerStyle.BorderStyle.Color = Color.DodgerBlue;
            m_Line1.MarkerStyle.PointShape        = PointShape.Cylinder;
            m_Line1.MarkerStyle.Visible           = true;
            m_Line1.ShadowStyle.Type              = ShadowType.GaussianBlur;

            m_Line2                               = (NLineSeries)chart.Series.Add(SeriesType.Line);
            m_Line2.Name                          = "Line 2";
            m_Line2.MultiLineMode                 = MultiLineMode.Overlapped;
            m_Line2.DataLabelStyle.Visible        = false;
            m_Line2.BorderStyle.Color             = Color.Orange;
            m_Line2.FillStyle                     = new NColorFillStyle(Color.Orange);
            m_Line2.MarkerStyle.FillStyle         = new NColorFillStyle(Color.Orange);
            m_Line2.MarkerStyle.BorderStyle.Color = Color.Orange;
            m_Line2.MarkerStyle.PointShape        = PointShape.Cylinder;
            m_Line2.MarkerStyle.Visible           = true;
            m_Line2.ShadowStyle.Type              = ShadowType.GaussianBlur;

            m_Bar = (NBarSeries)chart.Series.Add(SeriesType.Bar);
            m_Bar.DataLabelStyle.Visible = false;
            for (int i = 0; i < m_Bar.Values.Count; i++)
            {
                m_Bar.FillStyles[i] = new NColorFillStyle(WebExamplesUtilities.RandomColor());
            }
            m_Bar.Name = "Bar 1";

            GenerateData();

            // add header
            NLabel header = nChartControl1.Labels.AddHeader("Basic SVG Chart");

            header.TextStyle.BackplaneStyle.Visible = false;
            header.TextStyle.ShadowStyle.Type       = ShadowType.GaussianBlur;
            header.TextStyle.FillStyle = new NColorFillStyle(Color.Black);
            header.ContentAlignment    = ContentAlignment.BottomRight;
            header.Location            = new NPointL(new NLength(3, NRelativeUnit.ParentPercentage),
                                                     new NLength(3, NRelativeUnit.ParentPercentage));


            NImageResponse  svgImageResponse = new NImageResponse();
            NSvgImageFormat svgImageFormat   = new NSvgImageFormat();

            svgImageResponse.ImageFormat = svgImageFormat;
            nChartControl1.ServerSettings.BrowserResponseSettings.DefaultResponse = svgImageResponse;
        }
Example #4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            nChartControl1.Panels.Clear();

            // add watermarks

            string[] divIds = new string[] { "toyota",
                                             "chevrolet",
                                             "ford",
                                             "volkswagen",
                                             "hyundai",
                                             "nissan",
                                             "mazda" };

            nChartControl1.BackgroundStyle.FillStyle          = new NColorFillStyle(Color.LightGray);
            nChartControl1.BackgroundStyle.FrameStyle.Visible = false;

            // add header
            NLabel header = nChartControl1.Labels.AddHeader("Car Sales by Company");

            header.TextStyle.BackplaneStyle.Visible = false;
            header.TextStyle.TextFormat             = TextFormat.XML;
            header.TextStyle.ShadowStyle.Type       = ShadowType.GaussianBlur;
            header.TextStyle.FillStyle = new NColorFillStyle(Color.Black);
            header.DockMode            = PanelDockMode.Top;
            header.Margins             = new NMarginsL(0, 10, 0, 0);

            // by default the chart contains a cartesian chart which cannot display a pie series
            NDockPanel dockPanel = new NDockPanel();

            dockPanel.DockMode = PanelDockMode.Fill;
            dockPanel.PositionChildPanelsInContentBounds = true;
            dockPanel.Margins = new NMarginsL(10, 10, 10, 10);

            nChartControl1.Panels.Add(dockPanel);

            AddWatermark(dockPanel, "ToyotaLogo.png");
            AddWatermark(dockPanel, "ChevroletLogo.png");
            AddWatermark(dockPanel, "FordLogo.png");
            AddWatermark(dockPanel, "VolkswagenLogo.png");
            AddWatermark(dockPanel, "HyundaiLogo.png");
            AddWatermark(dockPanel, "NissanLogo.png");
            AddWatermark(dockPanel, "MazdaLogo.png");

            NPieChart pieChart = new NPieChart();

            dockPanel.ChildPanels.Add(pieChart);

            NPieSeries pieSeries = new NPieSeries();

            pieChart.Series.Add(pieSeries);

            // add some data
            pieSeries.AddDataPoint(new NDataPoint(11.6, "Toyota Corolla"));
            pieSeries.AddDataPoint(new NDataPoint(9.7, "Chevrolet Cruze"));
            pieSeries.AddDataPoint(new NDataPoint(9.3, "Ford Focus"));
            pieSeries.AddDataPoint(new NDataPoint(7.1, "Volkswagen Jetta"));
            pieSeries.AddDataPoint(new NDataPoint(7.0, "Hyundai Elantra"));
            pieSeries.AddDataPoint(new NDataPoint(6.1, "Nissan Versa"));
            pieSeries.AddDataPoint(new NDataPoint(5.9, "Mazda 3"));
            pieSeries.AddDataPoint(new NDataPoint(43.4, "Other"));

            pieSeries.PieStyle  = PieStyle.Torus;
            pieSeries.LabelMode = PieLabelMode.Center;

            // configure interactivity for data points
            for (int i = 0; i < pieSeries.Values.Count; i++)
            {
                NInteractivityStyle interactivityStyle = new NInteractivityStyle();

                if (i < nChartControl1.Watermarks.Count)
                {
                    string watermarkId = new NElementIdentifier(nChartControl1.Watermarks[i].Id).ToString();
                    interactivityStyle.CustomMapAreaAttribute.JScriptAttribute = "onmouseover = 'ShowWatermark(evt, \"" + watermarkId + "\", \"" + divIds[i] + "\")'";
                }
                else
                {
                    interactivityStyle.CustomMapAreaAttribute.JScriptAttribute = "onmouseover = 'ShowWatermark(evt, null, null)'";
                }

                pieSeries.InteractivityStyles.Add(i, interactivityStyle);
            }

            nChartControl1.InteractivityStyle.CustomMapAreaAttribute.JScriptAttribute = "onmouseover = 'ShowWatermark(evt, null, null)'";

            // apply style sheet
            NStyleSheet styleSheet = NStyleSheet.CreatePredefinedStyleSheet(PredefinedStyleSheet.BrightMultiColor);

            styleSheet.Apply(nChartControl1.Document);

            // configure the control to generate SVG.
            NImageResponse  imageResponse  = new NImageResponse();
            NSvgImageFormat svgImageFormat = new NSvgImageFormat();

            svgImageFormat.EnableInteractivity = true;
            svgImageFormat.CustomScript        = GetScript();
            svgImageFormat.EmbedImagesInSvg    = true;
            svgImageFormat.EmbeddedImageFormat = new NJpegImageFormat();

            Hashtable attributes = new Hashtable();

            attributes["preserveAspectRatio"] = "yMid slice";
//			attributes["onload"] = "Initialize(evt)";
            svgImageFormat.Attributes = attributes;
            imageResponse.ImageFormat = svgImageFormat;

            nChartControl1.ServerSettings.BrowserResponseSettings.DefaultResponse = imageResponse;
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            nChartControl1.BackgroundStyle.FrameStyle.Visible = false;

            NChart     chart;
            NBarSeries bar;

            nChartControl1.Legends[0].SetPredefinedLegendStyle(PredefinedLegendStyle.Bottom);

            chart            = nChartControl1.Charts[0];
            chart.BoundsMode = BoundsMode.Fit;
            chart.Location   = new NPointL(new NLength(20, NRelativeUnit.ParentPercentage),
                                           new NLength(20, NRelativeUnit.ParentPercentage));
            chart.Size = new NSizeL(new NLength(60, NRelativeUnit.ParentPercentage),
                                    new NLength(60, NRelativeUnit.ParentPercentage));

            chart.Depth = 20;
            bar         = (NBarSeries)chart.Series.Add(SeriesType.Bar);

            bar.AddDataPoint(new NDataPoint(100 + Random.Next(100), "Toyota", new NColorFillStyle(Color.Red)));
            bar.AddDataPoint(new NDataPoint(100 + Random.Next(100), "Volkswagen", new NColorFillStyle(Color.Gold)));
            bar.AddDataPoint(new NDataPoint(100 + Random.Next(100), "Ford", new NColorFillStyle(Color.Chocolate)));
            bar.AddDataPoint(new NDataPoint(100 + Random.Next(100), "Mazda", new NColorFillStyle(Color.LimeGreen)));

            bar.Legend.Mode   = SeriesLegendMode.DataPoints;
            bar.Legend.Format = "<label>";

            // add urls to redirect to

            NInteractivityStyle interactivityStyle = new NInteractivityStyle("Click here to jump to Toyota home page", CursorType.Hand);

            interactivityStyle.UrlLink.Url             = "http://www.toyota.com";
            interactivityStyle.UrlLink.OpenInNewWindow = OpenLinkInNewWindowCheckBox.Checked;
            bar.InteractivityStyles.Add(0, interactivityStyle);

            interactivityStyle                         = new NInteractivityStyle("Click here to jump to VW home page", CursorType.Hand);
            interactivityStyle.UrlLink.Url             = "http://www.vw.com";
            interactivityStyle.UrlLink.OpenInNewWindow = OpenLinkInNewWindowCheckBox.Checked;
            bar.InteractivityStyles.Add(1, interactivityStyle);

            interactivityStyle                         = new NInteractivityStyle("Click here to jump to Ford home page", CursorType.Hand);
            interactivityStyle.UrlLink.Url             = "http://www.ford.com";
            interactivityStyle.UrlLink.OpenInNewWindow = OpenLinkInNewWindowCheckBox.Checked;
            bar.InteractivityStyles.Add(2, interactivityStyle);

            interactivityStyle                         = new NInteractivityStyle("Click here to jump to Mazda home page", CursorType.Hand);
            interactivityStyle.UrlLink.Url             = "http://www.mazda.com";
            interactivityStyle.UrlLink.OpenInNewWindow = OpenLinkInNewWindowCheckBox.Checked;
            bar.InteractivityStyles.Add(3, interactivityStyle);

            for (int i = 0; i < bar.Values.Count; i++)
            {
                bar.FillStyles[i] = new NColorFillStyle(WebExamplesUtilities.RandomColor());
            }

            chart.LightModel.SetPredefinedLightModel(PredefinedLightModel.NorthernLights);
            chart.Projection.SetPredefinedProjection(PredefinedProjection.Orthogonal);

            // add header
            NLabel header = nChartControl1.Labels.AddHeader("Car Sales per Company<br/><font size = '10'>Demonstrates anchor SVG tags</font>");

            header.TextStyle.BackplaneStyle.Visible = false;
            header.TextStyle.TextFormat             = TextFormat.XML;
            header.TextStyle.FillStyle = new NColorFillStyle(Color.Black);
            header.ContentAlignment    = ContentAlignment.BottomRight;
            header.Location            = new NPointL(new NLength(2, NRelativeUnit.ParentPercentage),
                                                     new NLength(2, NRelativeUnit.ParentPercentage));

            NImageResponse  imageResponse  = new NImageResponse();
            NSvgImageFormat svgImageFormat = new NSvgImageFormat();

            svgImageFormat.EnableInteractivity = true;
            svgImageFormat.CustomScript        = "";

            imageResponse.ImageFormat = svgImageFormat;

            nChartControl1.ServerSettings.BrowserResponseSettings.DefaultResponse = imageResponse;
        }