Exemplo n.º 1
0
        public void FillChart(SS.UserModel.IChart chart, params IChartAxis[] axis)
        {
            if (!(chart is XSSFChart))
            {
                throw new ArgumentException("Chart must be instance of XSSFChart");
            }

            XSSFChart   xssfChart      = (XSSFChart)chart;
            CT_PlotArea plotArea       = xssfChart.GetCTChart().plotArea;
            int         allSeriesCount = plotArea.GetAllSeriesCount();
            CT_BarChart barChart       = plotArea.AddNewBarChart();

            barChart.AddNewVaryColors().val = 0;

            for (int i = 0; i < series.Count; ++i)
            {
                Series s = (Series)series[i];
                s.SetId(allSeriesCount + i);
                s.SetOrder(allSeriesCount + i);
                s.AddToChart(barChart);
            }

            foreach (IChartAxis ax in axis)
            {
                barChart.AddNewAxId().val = (uint)ax.Id;
            }
        }
Exemplo n.º 2
0
            internal void AddToChart(CT_BarChart ctBarChart)
            {
                CT_BarSer      ctBarSer   = ctBarChart.AddNewSer();
                CT_BarGrouping ctGrouping = ctBarChart.AddNewGrouping();

                ctGrouping.val = ST_BarGrouping.clustered;
                ctBarSer.AddNewIdx().val        = (uint)id;
                ctBarSer.AddNewOrder().val      = (uint)order;
                CT_Boolean ctNoInvertIfNegative = new CT_Boolean();

                ctNoInvertIfNegative.val  = 0;
                ctBarSer.invertIfNegative = ctNoInvertIfNegative;

                CT_BarDir ctBarDir = ctBarChart.AddNewBarDir();

                ctBarDir.val = ST_BarDir.col;

                CT_AxDataSource catDS = ctBarSer.AddNewCat();

                XSSFChartUtil.BuildAxDataSource(catDS, categories);
                CT_NumDataSource valueDS = ctBarSer.AddNewVal();

                XSSFChartUtil.BuildNumDataSource(valueDS, values);

                if (IsTitleSet)
                {
                    ctBarSer.tx = GetCTSerTx();
                }

                if (fillColor != null)
                {
                    ctBarSer.spPr = new OpenXmlFormats.Dml.Chart.CT_ShapeProperties();
                    CT_SolidColorFillProperties ctSolidColorFillProperties = ctBarSer.spPr.AddNewSolidFill();
                    CT_SRgbColor ctSRgbColor = ctSolidColorFillProperties.AddNewSrgbClr();
                    ctSRgbColor.val = fillColor;
                }
            }