/***************************************************/ public static string ToSVGString(this SVGObject svgObject) { if (svgObject == null) { BH.Engine.Reflection.Compute.RecordError("Cannot convert a null SVG object."); return(""); } string geometryString = "<g " + ToSVGString(svgObject.Style) + ">\n"; for (int i = 0; i < svgObject.Shapes.Count; i++) { geometryString += svgObject.Shapes[i].IToSVGString(); if (svgObject.Shapes.Count > 1) { geometryString += "\n"; } } if (svgObject.Shapes.Count == 1) { geometryString += "\n"; } geometryString += "</g>\n"; return(geometryString); }
/***************************************************/ /**** Public Methods ****/ /***************************************************/ public static BoundingBox Bounds(this SVGObject svg) { BoundingBox bb = new BoundingBox(); List <IGeometry> geometry = svg.Shapes; for (int i = 0; i < svg.Shapes.Count; i++) { bb += Engine.Geometry.Query.IBounds(svg.Shapes[i]); } return(bb); }
/***************************************************/ /**** Public Methods ****/ /***************************************************/ public static BoundingBox Bounds(this SVGObject svg) { if (svg == null) { BH.Engine.Reflection.Compute.RecordError("Cannot query the bounding box of a null SVG object."); return(null); } BoundingBox bb = new BoundingBox(); List <IGeometry> geometry = svg.Shapes; for (int i = 0; i < svg.Shapes.Count; i++) { bb += Engine.Geometry.Query.IBounds(svg.Shapes[i]); } return(bb); }
/***************************************************/ public static string ToSVGString(this SVGObject svgObject) { string geometryString = "<g " + ToSVGString(svgObject.Style) + ">\n"; for (int i = 0; i < svgObject.Shapes.Count; i++) { geometryString += svgObject.Shapes[i].IToSVGString(); if (svgObject.Shapes.Count > 1) { geometryString += "\n"; } } if (svgObject.Shapes.Count == 1) { geometryString += "\n"; } geometryString += "</g>\n"; return(geometryString); }
private void Button1_Click(object sender, EventArgs e) { DialogResult dialogResult = openFileDialog1.ShowDialog(); if (dialogResult.Equals(DialogResult.OK)) { StreamReader fileIN; // fileName = openFileDialog1.FileName; fileIN = new StreamReader(fileName); string tableTitle = fileIN.ReadLine(); string[] values; while (fileIN.Peek() != -1) { values = fileIN.ReadLine().Split(','); vehicleType.Add(values[0]); vehicleYear2018Sales.Add(Int32.Parse(values[1])); vehicleYear2019Sales.Add(Int32.Parse(values[2])); } fileIN.Close(); } // Plotting the Data in a graph //salesBarGraph.Titles.Add(tableName); //salesBarGraph.Series.Add("2019"); //salesBarGraph.Series[0].Points.DataBindY(vehicleYear2018Sales); //salesBarGraph.Series[0].LegendText = "2018"; //salesBarGraph.Series[1].Points.DataBindY(vehicleYear2019Sales); //for (int i = 0; i < vehicleType.Count; i++) // salesBarGraph.Series[0].Points[i].AxisLabel = vehicleType[i]; //salesBarGraph.SaveImage("VehicleSales.emf", ChartImageFormat.Emf); //mktShareChart.Titles.Add("Market Share of Vehicles 2019"); //mktShareChart.Series[0].Points.DataBindY(vehicleYear2019Sales); //mktShareChart.Series[0].LegendText = "2019"; //for (int i=0; i<vehicleType.Count; i++) //mktShareChart.Series[0].Points[i].AxisLabel = vehicleType[i]; //mktShareChart.SaveImage("Market Share of 2019.emf", ChartImageFormat.Emf); //Convert Charts To SVG DataTable table1 = new DataTable("Vehicle Sales 2018 & 2019"), table2 = new DataTable("2019 Market Share"); //table1 = ConvertToDataTable(vehicleYear2018Sales); //table2 = ConvertToDataTable(vehicleYear2019Sales); table1.Columns.Add("Type", typeof(string)); table1.Columns.Add("Quantity", typeof(double)); table2.Columns.Add("Type", typeof(string)); table2.Columns.Add("Quantity", typeof(double)); for (int i = 0; i < vehicleYear2018Sales.Count; i++) { table1.Rows.Add("2018 " + vehicleType[i], vehicleYear2018Sales[i].ToString()); table1.Rows.Add("2019 " + vehicleType[i], vehicleYear2019Sales[i].ToString()); table2.Rows.Add(vehicleType[i], vehicleYear2019Sales[i].ToString()); } SVGObject svg = new SVGObject(); HistogramChart his = new HistogramChart(300, 300, table1.Rows.Count); //his. // Credits to Gerard Viader XmlDocument xml = his.GenerateChart(table1, table1.Columns["Type"].ToString(), table1.Columns["Quantity"].ToString()); xml.Save("2018 & 2019 Vehicle Sales.svg"); PieChart pie = new PieChart(500, 500, table2.Rows.Count); xml = pie.GenerateChart(table2, table2.Columns["Type"].ToString(), table2.Columns["Quantity"].ToString()); xml.Save("2019 Market Share.svg"); //xml = his.GenerateChart(table1, table1.Columns["Type"].ToString(), table1.Columns["2019"].ToString()); //xml.Save("2019 Market Share.svg"); Application.Exit(); }