예제 #1
0
        /// <summary>
        /// Fills a <see cref="OfficeOpenXml.Drawing.Chart.ExcelChart"/> object with model data.
        /// </summary>
        /// <param name="chart"><see cref="OfficeOpenXml.Drawing.Chart.ExcelChart"/> object.</param>
        /// <param name="model">Chart model definition.</param>
        /// <exception cref="System.ArgumentNullException">If <paramref name="chart" /> is <c>null</c>.</exception>
        /// <exception cref="System.ArgumentNullException">If <paramref name="model" /> is <c>null</c>.</exception>
        public static void FormatFromModel(this ExcelChart chart, ChartModel model)
        {
            SentinelHelper.ArgumentNull(chart);
            SentinelHelper.ArgumentNull(model);

            ChartXmlHelper.ChartXml = chart.ChartXml;

            chart.SetSize(model.ChartSize.Width, model.ChartSize.Height);
            chart.FormatFromModel(model.Location);
            chart.Fill.Color = model.GetBackColor();

            chart.Border.FormatFromModel(KnownChartElement.Self, model.Border);
            chart.Title.FormatFromModel(KnownChartElement.ChartTitle, model.Title);
            chart.Legend.FormatFromModel(model.Legend);
            chart.PlotArea.FormatFromModel(model.Plots);
            chart.Axis.FormatFromModel(model.Axes);
        }