상속: IDisposable
예제 #1
0
        private void pFill(cWebChart chart, DataRowCollection rows, String strFormat) 
        {
            int i = 0;
            t_SerieValue[] values = null;
            cReportChartSerie serie = null;
            int idxSerie = 0;

            if (m_top == 0) { m_top = 50; }

            // TODO: we need the rows dimension. remeber rows is a matrix (cols by rows)
            if (rows.Count < 0) { return; }

            // TODO: we need the rows dimension. remeber rows is a matrix (cols by rows)
            if (rows.Count < m_top) {
                // TODO: we need the rows dimension. remeber rows is a matrix (cols by rows)
                pRedim(ref values, rows.Count);
            } 
            else {
                pRedim(ref values, m_top - 1);
            }

            for (int _i = 0; _i < m_series.count(); _i++) {
                serie = m_series.item(_i);

                // At the time we only support two series
                //
                idxSerie = idxSerie + 1;
                if (idxSerie > 2) { return; }

                pGetSerieValues(rows, 
                                values, 
                                serie.getValueIndex(), 
                                serie.getLabelIndex(), 
                                m_chartType == csRptChartType.PIE);

                for (i = 0; i < values.Length; i++) {

                    if (values[i].idx != -1) {
                        if (idxSerie == 1) {
                            cWebChartItem w_add = chart.getItems().add(null);
                            w_add.setPrimaryValue(values[i].value);
                            w_add.setPrimaryLabel(cReportGlobals.format(values[i].label, strFormat));
                            w_add.setPieLabel(cReportGlobals.format(values[i].label, strFormat));
                            w_add.setAlternateValue(0);
                        } 
                        else if (idxSerie == 2) {
                            cWebChartItem w_item = chart.getItems().item(i);
                            w_item.setAlternateValue(values[i].value);
                            w_item.setPieLabel(cReportGlobals.format(values[i].label, strFormat));
                            w_item.setAltLabel(cReportGlobals.format(values[i].label, strFormat));
                        }
                    }
                }

                if ((values.Length > m_top - 1) && m_chartType == csRptChartType.PIE) {

                    cWebChartItem w_item = chart.getItems().item(chart.getItems().count()-1);
                    w_item.setPrimaryLabel("Otros");
                    w_item.setPieLabel("Otros");
                }

            }

            if (chart.getItems().count() > 0) {
                chart.getItems().item(0).setExplode(true);
            }
        }
예제 #2
0
        public bool make(DataRowCollection rows, String strFormat, bool bIsForWeb, String fileName)
        {
            // we need to delete any previous work image
            //
            pDestroyImage();

            if (rows == null)
            {
                return false;
            }

            cWebChart chart = new cWebChart();

            chart.newChartType((csRptChartType)m_chartType, m_chartTitle);

            pFill(chart, rows, strFormat);

            chart.setColorPrimary((csColors)m_series.item(0).getColor());
            chart.setLabelPrimary(cReportGlobals.getRealName(m_series.item(0).getValueFieldName()));
            if (m_series.count() > 1)
            {
                chart.setColorAlternate(m_series.item(1).getColor());
                chart.setLabelAlternate(cReportGlobals.getRealName(m_series.item(1).getValueFieldName()));
            }
            chart.setGridLines(m_chartLineStyle);
            chart.setOutlineBars(m_chartBarOutline);
            chart.setShowValues(m_chartShowValues);
            chart.setShowLegend((m_chartType == csRptChartType.BAR) ? false : m_chartShowValues);

            chart.setThickness(m_pieThickness);
            chart.setDiameter(m_pieDiameter);

            if (!bIsForWeb)
            {
                fileName = cUtil.getValidPath(System.IO.Path.GetTempPath()) + "~ChartImage";
            }

            chart.setFormat(m_imageFormat);

            // saveToFile
            chart.setSaveTo(1);
            chart.setFileName(fileName);

            pKillFile(fileName);

            chart.setCopyRight(m_copyright);
            chart.renderWebChartImage();

            if (!bIsForWeb)
            {
                loadChart(fileName);
            }

            m_chartCreated = true;
            return true;

            chart.Dispose();
        }