Exemple #1
0
        public void UpdateChart()
        {
            foreach (SheetView Sheet in FpSpread.Sheets)
            {
                //支持嵌入的图表
                int RowCount    = Sheet.GetLastNonEmptyRow(NonEmptyItemFlag.Style);
                int ColumnCount = Sheet.GetLastNonEmptyColumn(NonEmptyItemFlag.Style);
                for (int i = 0; i <= RowCount; i++)
                {
                    for (int j = 0; j <= ColumnCount; j++)
                    {
                        if (Sheet.Cells[i, j].CellType is ChartCellType)
                        {
                            ChartCellType ChartType = Sheet.Cells[i, j].CellType as ChartCellType;
                            Rectangle     r         = FpSpread.GetCellRectangle(0, 0, i, j);
                            ChartType.ChartSize   = r.Size;
                            ChartType.ActiveSheet = Sheet;
                            ChartType.UpdateChart();
                        }
                    }
                }

                //支持浮动的图表
                foreach (IElement Element in Sheet.DrawingContainer.ContainedObjects)
                {
                    if (Element is ChartShape)
                    {
                        ChartShape Shape = Element as ChartShape;
                        Shape.ActiveSheet = Sheet;
                        Shape.Locked      = false;
                        Shape.UpdateChart();
                    }
                }
            }
        }
		public override Windows.Controls.RadDiagramShape CreateShape()
		{
			var shape = new ChartShape 
			{
				Symbol = ImageToolboxItem.DefaultSymbol
			};
			return shape;
		}
Exemple #3
0
        /// <summary>
        /// writes the chart
        /// </summary>
        /// <param name="wb"></param>
        /// <param name="compHistory"></param>
        /// <param name="columnOffset"></param>
        private void WriteChart(WorkBook wb, ComparisonHistoryModel compHistory, int columnOffset, int sheetIndex)
        {
            cLogger.DebugFormat("write chart sheetIndex: {0}", sheetIndex);

            // transform sheet into chart sheeet

            ChartShape chartShape = wb.addChartSheet(sheetIndex);

            wb.Sheet = sheetIndex;

            wb.PrintScaleFitToPage = true;
            wb.PrintLandscape      = true;

            wb.setSheetName(sheetIndex, string.Format("Diagram_{0}", compHistory.Name));
            chartShape.ChartType = ChartShape.Scatter;

            chartShape.setAxisTitle(ChartShape.XAxis, 0, "Evaluation Run ID");
            chartShape.setAxisTitle(ChartShape.YAxis, 0, "Runtime [ms]");

            ChartFormat tFormat = chartShape.PlotFormat;

            tFormat.setLineNone();

            chartShape.setSeriesName(0, compHistory.Name);
            var format = chartShape.getSeriesFormat(0);

            format.MarkerStyle = ChartFormat.MarkerCircle;
            chartShape.setSeriesFormat(0, format);

            string xFormula = string.Format("data!${0}${1}:${0}${2}", GetDataColumnIndex(columnOffset), 2, compHistory.Data.Count());

            chartShape.setSeriesXValueFormula(0, xFormula);
            string yFormula = string.Format("data!${0}${1}:${0}${2}", GetDataColumnIndex(columnOffset + 2), 2, compHistory.Data.Count());

            cLogger.DebugFormat("xFormula: {0}, yFormula: {1}", xFormula, yFormula);

            chartShape.setSeriesYValueFormula(0, yFormula);
        }