/// <summary> /// create the chart property /// </summary> /// <param name="style"></param> /// <param name="node"></param> /// <returns></returns> private ChartProperties CreateChartProperties(IStyle style, XmlNode node) { ChartProperties chartProperty = new ChartProperties(style); chartProperty.Node = node; return(chartProperty); }
/** * */ override public void afterReportInit() { try { AreaChartProperties areaChartProperties = new AreaChartProperties(); double[][] data = new double[][] { new double[] { 10, 15, 30, 53 }, new double[] { 6, 30, 10, 21 }, new double[] { 20, 25, 20, 8 } }; Paint[] paints = { new Color(0, 255, 0, 100), new Color(255, 0, 0, 100), new Color(0, 0, 255, 100) }; string[] legendLabels = { "Games", "Events", "Players" }; AxisChartDataSet axisChartDataSet = new AxisChartDataSet(data, legendLabels, paints, ChartType.AREA, areaChartProperties); string[] axisLabels = { "January", "March", "May", "June" }; DataSeries dataSeries = new DataSeries(axisLabels, "Months", "People", "Popular Events"); dataSeries.addIAxisPlotDataSet(axisChartDataSet); ChartProperties chartProperties = new ChartProperties(); AxisProperties axisProperties = new AxisProperties(); axisProperties.setYAxisRoundValuesToNearest(0); LegendProperties legendProperties = new LegendProperties(); AxisChart axisChart = new AxisChart(dataSeries, chartProperties, axisProperties, legendProperties, 500, 350); BufferedImage bufferedImage = new BufferedImage(500, 350, BufferedImage.TYPE_INT_RGB); axisChart.setGraphics2D(bufferedImage.createGraphics()); axisChart.render(); base.setVariableValue("ChartImage", bufferedImage); } catch (ChartDataException chartDataException) { throw new JRScriptletException(chartDataException); } }
public void InitializeStage(Project initProj, int difficulty, ProjectController projCtrl) { projectController = projCtrl; tGridPool.Initialize(); comboParent.SetActive(true); comboController.stage = this; noteSpeedChangeSetting.SetActive(true); musicSpeedChangeSetting.SetActive(true); stageActivated = true; chart = initProj.charts[difficulty]; diff = difficulty; editor.chart = chart; editor.ActivateEditor(); ChartProperties.GetInGameNoteIds(initProj.charts[difficulty], out inGameNoteIDs); ChartProperties.GetCollidedNotes(initProj.charts[difficulty], out collided); musicLength = musicSource.clip.length; timeSlider.minValue = 0.0f; timeSlider.maxValue = musicLength; timeSlider.value = 0.0f; noteSpeedIntText.text = (chartPlaySpeed / 2).ToString(); noteSpeedDeciText.text = (chartPlaySpeed % 2 * 5).ToString(); musicSpeedIntText.text = (musicPlaySpeed / 10).ToString(); musicSpeedDeciText.text = (musicPlaySpeed % 10).ToString(); OnSliderValueChanged(); }
/// <summary> /// create the chart property /// </summary> /// <param name="style"></param> /// <param name="node"></param> /// <returns></returns> private static ChartProperties CreateChartProperties(IStyle style, XElement node) { ChartProperties chartProperty = new ChartProperties(style) { Node = node }; return(chartProperty); }
private object GetChart() { ChartProperties chart = new ChartProperties(); PropertyTable properties = new PropertyTable(chart); // Starter starter = new DesignStarter(); // starter.Model = engine; // starter.Run(); // properties.SetAfterInitialize(); // LoadIndicators(engine); return(properties); }
private void CreatePnlChart(IEnumerable <BacktestUnrealizedPnlSerie> pnlSeries) { if (!pnlSeries.IsNullOrEmpty()) { ChartModel = new ChartProperties() { Legend = new Legend() { Visible = true }, PrimaryXAxis = new Axis() { LabelFormat = "n1", Title = new Title() { Text = "Duration (hours)" } }, PrimaryYAxis = new Axis() { RoundingPlaces = 1, Title = new Title() { Text = "Unr Pnl (pips)" } } }; ChartModel.Series.AddRange(pnlSeries.Select(s => { var series = new Series() { Name = s.TradeDescription, Tooltip = new NewTooltip() { Template = "toolTipTemplate", Visible = true }, Type = SeriesType.Line }; series.Points.AddRange(s.Points.Select(p => new Points() { X = ((double)p.TimeInSeconds / 3600).ToString(), Y = p.UnrealizedPnlInPips })); return(series); })); } }
private ChartProperties ConvertChartObject(string ChartModel) { JavaScriptSerializer serializer = new JavaScriptSerializer(); IEnumerable div = (IEnumerable)serializer.Deserialize(ChartModel, typeof(IEnumerable)); ChartProperties chartProp = new ChartProperties(); foreach (KeyValuePair <string, object> ds in div) { var property = chartProp.GetType().GetProperty(ds.Key, BindingFlags.Instance | BindingFlags.Public | BindingFlags.IgnoreCase); if (property != null) { Type type = property.PropertyType; string serialize = serializer.Serialize(ds.Value); object value = serializer.Deserialize(serialize, type); property.SetValue(chartProp, value, null); } } return(chartProp); }
public static BufferedImage getJChart() { BufferedImage bufferedImage = null; try { //string reports_dir = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "reports"); //string fileName = System.IO.Path.Combine(reports_dir, "AreaChart.jpg"); //bufferedImage = ImageIO.read(new File(fileName)); AreaChartProperties areaChartProperties = new AreaChartProperties(); double[][] data = new double[][] { new double[] { 10, 15, 30, 53 }, new double[] { 6, 30, 10, 21 }, new double[] { 20, 25, 20, 8 } }; Paint[] paints = { new Color(0, 255, 0, 100), new Color(255, 0, 0, 100), new Color(0, 0, 255, 100) }; String[] legendLabels = { "Games", "Events", "Players" }; AxisChartDataSet axisChartDataSet = new AxisChartDataSet(data, legendLabels, paints, ChartType.AREA, areaChartProperties); String[] axisLabels = { "January", "March", "May", "June" }; DataSeries dataSeries = new DataSeries(axisLabels, "Months", "People", "Popular Events"); dataSeries.addIAxisPlotDataSet(axisChartDataSet); ChartProperties chartProperties = new ChartProperties(); AxisProperties axisProperties = new AxisProperties(); axisProperties.setYAxisRoundValuesToNearest(0); LegendProperties legendProperties = new LegendProperties(); AxisChart axisChart = new AxisChart(dataSeries, chartProperties, axisProperties, legendProperties, 500, 350); bufferedImage = new BufferedImage(500, 350, BufferedImage.TYPE_INT_RGB); axisChart.setGraphics2D(bufferedImage.createGraphics()); axisChart.render(); } catch (ChartDataException chartDataException) { throw new JRScriptletException(chartDataException); } return(bufferedImage); }
public void ExportChart(string Data, string ChartModel) { // declaration ChartProperties obj = ConvertChartObject(ChartModel); string type = obj.ExportSettings.Type.ToString().ToLower(); string fileName = obj.ExportSettings.FileName; string orientation = obj.ExportSettings.Orientation.ToString(); if (type == "svg") // for svg export { StringWriter oStringWriter = new StringWriter(); string data = HttpUtility.HtmlDecode(Data); data = HttpUtility.UrlDecode(Data); data = System.Uri.UnescapeDataString(Data); oStringWriter.WriteLine(System.Uri.UnescapeDataString(Data)); Response.ContentType = "text/plain"; Response.AddHeader("Content-Disposition", String.Format("attachment;filename={0}", (obj.ExportSettings.FileName + ".svg"))); Response.Clear(); using (StreamWriter writer = new StreamWriter(Response.OutputStream)) { data = oStringWriter.ToString(); writer.Write(oStringWriter.ToString()); } Response.End(); } else if (type == "xlsx") // to export chart as excel { List <ExportChartData> chartData = new List <ExportChartData>(); chartData.Add(new ExportChartData("John", 10)); chartData.Add(new ExportChartData("Jake", 12)); chartData.Add(new ExportChartData("Peter", 18)); chartData.Add(new ExportChartData("James", 11)); chartData.Add(new ExportChartData("Mary", 9.7)); ExcelExport exp = new ExcelExport(); exp.Export(obj, (IEnumerable)chartData, fileName + ".xlsx", ExcelVersion.Excel2010, null, null); } else { Data = Data.Remove(0, Data.IndexOf(',') + 1); MemoryStream stream = new MemoryStream(Convert.FromBase64String(Data)); if (type == "docx") // to export as word document { WordDocument document = new WordDocument(); IWSection section = document.AddSection(); IWParagraph paragraph = section.AddParagraph(); //Set orientation based on chart width Image img = Image.FromStream(stream); if (obj.ExportSettings.Orientation.ToString() == "Landscape" || section.PageSetup.ClientWidth < img.Width) { section.PageSetup.Orientation = PageOrientation.Landscape; } else { section.PageSetup.Orientation = PageOrientation.Portrait; } img.Dispose(); paragraph.AppendPicture(Image.FromStream(stream)); document.Save(fileName + ".doc", Syncfusion.DocIO.FormatType.Doc, HttpContext.ApplicationInstance.Response, Syncfusion.DocIO.HttpContentDisposition.Attachment); } else if (type == "pdf") // to export as PDF { PdfDocument pdfDoc = new PdfDocument(); pdfDoc.Pages.Add(); //Set chart width as pdf page width Image img = Image.FromStream(stream); pdfDoc.Pages[0].Section.PageSettings.Width = img.Width; img.Dispose(); if (obj.ExportSettings.Orientation.ToString() == "Landscape") { pdfDoc.Pages[0].Section.PageSettings.Orientation = PdfPageOrientation.Landscape; } else { pdfDoc.Pages[0].Section.PageSettings.Orientation = PdfPageOrientation.Portrait; } pdfDoc.Pages[0].Graphics.DrawImage(PdfImage.FromStream(stream), new PointF(10, 30)); pdfDoc.Save(obj.ExportSettings.FileName + ".pdf", HttpContext.ApplicationInstance.Response, HttpReadType.Save); pdfDoc.Close(); } else // to export as image { stream.WriteTo(Response.OutputStream); Response.ContentType = "application/octet-stream"; Response.AddHeader("Content-Disposition", String.Format("attachment;filename={0}", fileName + "." + type)); Response.Flush(); stream.Close(); stream.Dispose(); } } }