public static void Run() { //ExStart:SetExternalWorkbook // The path to the documents directory. string dataDir = RunExamples.GetDataDir_Charts(); using (Presentation pres = new Presentation()) { IChart chart = pres.Slides[0].Shapes.AddChart(ChartType.Pie, 50, 50, 400, 600, false); IChartData chartData = chart.ChartData; chartData.SetExternalWorkbook(dataDir + "externalWorkbook.xlsx"); chartData.Series.Add(chartData.ChartDataWorkbook.GetCell(0, "B1"), ChartType.Pie); chartData.Series[0].DataPoints.AddDataPointForPieSeries(chartData.ChartDataWorkbook.GetCell(0, "B2")); chartData.Series[0].DataPoints.AddDataPointForPieSeries(chartData.ChartDataWorkbook.GetCell(0, "B3")); chartData.Series[0].DataPoints.AddDataPointForPieSeries(chartData.ChartDataWorkbook.GetCell(0, "B4")); chartData.Categories.Add(chartData.ChartDataWorkbook.GetCell(0, "A2")); chartData.Categories.Add(chartData.ChartDataWorkbook.GetCell(0, "A3")); chartData.Categories.Add(chartData.ChartDataWorkbook.GetCell(0, "A4")); pres.Save(dataDir + "Presentation_with_externalWorkbook.pptx", SaveFormat.Pptx); } //ExEnd:SetExternalWorkbook }
public static void Insert(IChartData ChartData) { SqlParameter[] _parameters = { new SqlParameter("@ChartId", ChartData.ChartId) , new SqlParameter("@ReportDate", ChartData.ReportDate) , new SqlParameter("@Info", ChartData.NewInfo) }; SqlHelper.ExecuteNonQuery(ConnectionString, "sp_ChartData_InsertInfo", _parameters); }
public static void Run() { //ExStart:SetExternalWorkbookFromNetwork string externalWbPath = @"http://606178d2.ngrok.io/webgrind/styles/2.xlsx"; LoadOptions opts = new LoadOptions(); opts.ResourceLoadingCallback = new WorkbookLoadingHandler(); using (Presentation pres = new Presentation(opts)) { IChart chart = pres.Slides[0].Shapes.AddChart(ChartType.Pie, 50, 50, 400, 600, false); IChartData chartData = chart.ChartData; (chartData as ChartData).SetExternalWorkbook(externalWbPath); } //ExEnd:SetExternalWorkbookFromNetwork }
public static void Run() { //ExStart:SetExternalWorkbookWithUpdateChartData // The path to the documents directory. string dataDir = RunExamples.GetDataDir_Charts(); using (Presentation pres = new Presentation()) { IChart chart = pres.Slides[0].Shapes.AddChart(ChartType.Pie, 50, 50, 400, 600, true); IChartData chartData = chart.ChartData; (chartData as ChartData).SetExternalWorkbook("http://path/doesnt/exists", false); pres.Save(dataDir + "SetExternalWorkbookWithUpdateChartData.pptx", SaveFormat.Pptx); } //ExEnd:SetExternalWorkbookWithUpdateChartData }
public void addMeasureGraph(IChartData chartData) { XmlDocument doc = new XmlDocument(); XmlElement root = doc.CreateElement("Graph"); root.SetAttribute("name", chartData.Title); switch (chartData.ChartType) { case (ChartType.BAR): root.SetAttribute("type", ChartType.BAR.ToString()); break; case (ChartType.MULTIBAR): root.SetAttribute("type", ChartType.MULTIBAR.ToString()); break; default: logger.Warn("Undefined ChartType " + chartData.ChartType.ToString()); return; //do NOT add the graph! } if (this.measuresController.addMeasureGraphToFile(this.SimRunId, root, MeasuresController.GraphCategory.SINGLEMEASURE)) { List<IChartData> list = new List<IChartData>(this.measureGraphs); list.Add(chartData); this.measureGraphs = list.ToArray(); } else { logger.Debug(String.Format( "Unable to save a new Measure Custom graph {0} for the Run ID: {1}", chartData.Title, this.SimRunId)); return; //do NOT add the graph! } this.displaySavedMeasureGraph(chartData); }
public void addRunToRunGraph(IChartData chartData, int[] selectedSimRunId) { XmlDocument doc = new XmlDocument(); XmlElement root = doc.CreateElement("Graph"); root.SetAttribute("name", chartData.Title); XmlElement element = null; XmlElement runs = null; XmlElement layer = null; List<String> layerList = new List<String>(); bool useSimRunAsX = false; switch (chartData.ChartType) { case (ChartType.LINEAR): root.SetAttribute("type", ChartType.LINEAR.ToString()); LinearChartData data = (LinearChartData)chartData; runs = doc.CreateElement("SimRuns"); foreach (int simRun in selectedSimRunId) { element = doc.CreateElement("SimRun"); element.SetAttribute("id", simRun.ToString()); runs.AppendChild(element); } root.AppendChild(runs); element = doc.CreateElement("XLabel"); element.SetAttribute("name", data.XAxisLabel); root.AppendChild(element); element = doc.CreateElement("YLabel"); element.SetAttribute("name", data.YAxisLabel); root.AppendChild(element); //Create Layers node and its Layer children element = doc.CreateElement("Layers"); element.SetAttribute("name", data.LayerName); foreach (LinearLayer l in data.Layers) { String prefix = null; String layerName = l.LayerLegend; foreach (int simRun in selectedSimRunId) { prefix = "SimRun " + simRun + ": "; if (l.LayerLegend.StartsWith(prefix)) { layerName = l.LayerLegend.Replace(prefix, ""); break; } } if (!layerList.Contains(layerName)) layerList.Add(layerName); } foreach (String lName in layerList) { layer = doc.CreateElement("Layer"); layer.SetAttribute("name", lName); element.AppendChild(layer); } element.SetAttribute("useSimRunAsX", useSimRunAsX.ToString().ToLower()); root.AppendChild(element); if (this.assessmentController.AddRunToRunGraphToFile(this.SimulationId, root)) { List<IChartData> list = new List<IChartData>(this.runtorunGraphs); list.Add(chartData); this.runtorunGraphs = list.ToArray(); break; } else { logger.Debug(String.Format( "Unable to save a new Run-To-Run graph {0} for the Simulation ID: {1}", chartData.Title, this.SimulationId)); return; //do NOT add the graph! } default: logger.Warn("Undefined ChartType " + chartData.ChartType.ToString()); return; //do NOT add the graph! } this.displaySavedRunToRunGraph(chartData); }
public void addCustomGraph(IChartData chartData) { XmlDocument doc = new XmlDocument(); XmlElement root = doc.CreateElement("Graph"); root.SetAttribute("name", chartData.Title); XmlElement element = null; XmlElement layer = null; switch(chartData.ChartType) { case (ChartType.LINEAR): root.SetAttribute("type", ChartType.LINEAR.ToString()); LinearChartData data = (LinearChartData)chartData; element = doc.CreateElement("XLabel"); element.SetAttribute("name", data.XAxisLabel); root.AppendChild(element); element = doc.CreateElement("YLabel"); element.SetAttribute("name", data.YAxisLabel); root.AppendChild(element); element = doc.CreateElement("Layers"); element.SetAttribute("name", data.LayerName); foreach (LinearLayer l in data.Layers) { layer = doc.CreateElement("Layer"); layer.SetAttribute("name", l.LayerLegend); element.AppendChild(layer); } root.AppendChild(element); if (this.assessmentController.AddCustomGraphToFile(this.SimRunId, root)) { List<IChartData> list = new List<IChartData>(this.customGraphs); list.Add(chartData); this.customGraphs = list.ToArray(); break; } else { logger.Debug(String.Format( "Unable to save a new Custom graph {0} for the SimRun ID: {1}", chartData.Title, this.SimRunId)); return; //do NOT add the graph! } default: logger.Warn("Undefined ChartType " + chartData.ChartType.ToString()); return; //do NOT add the graph! } this.displaySavedCustomGraph(chartData); }
public ChartThumbnail(IChartData chartData, String id) : this(chartData) { this.id = id; }
public ChartForm(IChartData chartData) : this() { this.chartData = chartData; this.createChart(); }
public void Plot(IChartData data, params IChartAxis[] axis) { data.FillChart(this, axis); }
/// <summary> /// Creates the ChartThumbnail object from the ChartData and adds all /// Mouse Events to it. /// </summary> /// <param name="chartData">The chart data.</param> /// <returns></returns> private ChartThumbnail createThumbnail(IChartData chartData) { ChartThumbnail thumbnail = new ChartThumbnail(chartData); thumbnail.MouseClick += new System.Windows.Forms.MouseEventHandler(this.thumbnail_Click); thumbnail.ChartThumbnailDeleted += new ChartThumbnail.ChartThumbnailDeletedHandler(thumbnail_ChartThumbnailDeleted); return thumbnail; }
public void SetChartData(IChartData cd) { _chartData = cd; }
private void buildBarChart(int runId, MeasureInfo measure) { DataTable chartTable = this.getMeasuredGraphDataTable(runId, measure); if (chartTable == null) { String message = "There is no data for the measure: " + measure.DisplayName; logger.Debug(message + " for Run " + runId); MessageBox.Show(message, "Graphing Error", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } String[] labels = new String[chartTable.Rows.Count]; double[] data = new double[labels.Length]; DataRow row = null; for (int j = 0; j < chartTable.Columns.Count; j++) { for (int i = 0; i < chartTable.Rows.Count; i++) { row = chartTable.Rows[i]; if (j == 0) { labels[i] = row[j].ToString(); } else { data[i] = Double.Parse(row[j].ToString()); } } } this.chartData = new BarChartData(measure.DisplayName, data, labels, null); }
/// <summary> /// Prepares the legend and calculates all needed forms, labels and colors. /// </summary> /// <param name="data"></param> public void ComputeLegend(IChartData data) { }
/// <summary> /// Create a ChartThumbnail from the ChartData and display it on the /// Run-To-Run Graphs Tab Panel. /// </summary> /// <param name="chartData">The chart data.</param> private void displaySavedRunToRunGraph(IChartData chartData) { this.rToRGraphsFlowPanel.Controls.Add(this.createThumbnail(chartData)); this.tabControl.SelectTab(this.rToRGraphsPage); }
private void displaySavedMeasureGraph(IChartData chartData) { this.measureGraphsFlowPanel.Controls.Add(this.createThumbnail(chartData)); this.tabControl.SelectTab(this.measureGraphPage); }
private void clear() { this.graphNameTextBox.Clear(); this.xAxisCombo.SelectedIndex = -1; this.yAxisCombo.SelectedIndex = -1; this.typeToGraphCombo.SelectedIndex = -1; this.itemsToGraphListBox.Items.Clear(); this.simRunAxisCheckBox.Checked = false; this.chartData = null; }
public void Plot(IChartData data, params IChartAxis[] axis) { data.FillChart(this, axis); }
private void okButton_Click(object sender, EventArgs e) { try { this.chartData = this.getGraphingData(); if (this.chartData.Title == null || this.chartData.Title.CompareTo(String.Empty) == 0) { MessageBox.Show("Graph Name can not be blank", "Graph Setup Error", MessageBoxButtons.OK, MessageBoxIcon.Error); this.chartData = null; } else if (isDuplicateChartName()) { MessageBox.Show("Graph Name '" + this.chartData.Title + "' already exists", "Graph Setup Error", MessageBoxButtons.OK, MessageBoxIcon.Error); this.chartData = null; } } catch (Exception ex) { this.chartData = null; logger.Debug(ex.Message); } }
public ChartThumbnail(IChartData chartData) : this() { this.chartData = chartData; this.createChart(); }
/// <summary> /// Prepares the legend and calculates all needed forms, labels and colors. /// </summary> /// <param name="data"></param> public void ComputeLegend(IChartData data) { if (!Legend.IsLegendCustom) { computedEntries.Clear(); // loop for building up the colors and labels used in the legend for (int i = 0; i < data.DataSetCount; i++) { IDataSet dataSet = data[i]; if (dataSet == null) { continue; } IList <SKColor> clrs = dataSet.Colors; int entryCount = dataSet.EntryCount; // if we have a barchart with stacked bars if (dataSet is IBarDataSet bds && bds.IsStacked) { IList <string> sLabels = bds.StackLabels; int minEntries = Math.Min(clrs.Count, bds.StackSize); for (int j = 0; j < minEntries; j++) { string label; if (sLabels.Count > 0) { int labelIndex = j % minEntries; label = labelIndex < sLabels.Count ? sLabels[labelIndex] : null; } else { label = null; } computedEntries.Add(new LegendEntry( label, dataSet.Form, dataSet.FormSize, dataSet.FormLineWidth, dataSet.FormLineDashEffect, clrs[j] )); } if (bds.Label != null) { // add the legend description label computedEntries.Add(new LegendEntry( dataSet.Label, Form.None, float.NaN, float.NaN, null, SKColors.Empty )); } } else if (dataSet is IPieDataSet pds) { for (int j = 0; j < clrs.Count && j < entryCount; j++) { computedEntries.Add(new LegendEntry( ((IDataSet <Data.PieEntry>)pds)[j].Label, dataSet.Form, dataSet.FormSize, dataSet.FormLineWidth, dataSet.FormLineDashEffect, clrs[j] )); } if (pds.Label != null) { // add the legend description label computedEntries.Add(new LegendEntry( dataSet.Label, Form.None, float.NaN, float.NaN, null, SKColors.Empty )); } } else if (dataSet is ICandleDataSet candle && candle.DecreasingColor != SKColors.Empty) { SKColor decreasingColor = candle.DecreasingColor; SKColor increasingColor = candle.IncreasingColor; computedEntries.Add(new LegendEntry( null, dataSet.Form, dataSet.FormSize, dataSet.FormLineWidth, dataSet.FormLineDashEffect, decreasingColor )); computedEntries.Add(new LegendEntry( dataSet.Label, dataSet.Form, dataSet.FormSize, dataSet.FormLineWidth, dataSet.FormLineDashEffect, increasingColor )); }