Search in sources :

Example 41 with JFreeChart

use of org.jfree.chart.JFreeChart in project adempiere by adempiere.

the class GraphBuilder method createAreaChart.

private JFreeChart createAreaChart() {
    // create the chart...
    JFreeChart chart = ChartFactory.createAreaChart(// chart title
    m_goal.getMeasure().getName(), // domain axis label
    m_X_AxisLabel, // range axis label
    m_Y_AxisLabel, // data
    dataset, // orientation
    PlotOrientation.VERTICAL, // include legend
    false, // tooltips?
    true, // URLs?
    true);
    setupCategoryChart(chart);
    return chart;
}
Also used : JFreeChart(org.jfree.chart.JFreeChart)

Example 42 with JFreeChart

use of org.jfree.chart.JFreeChart in project adempiere by adempiere.

the class GraphBuilder method createLineChart.

private JFreeChart createLineChart() {
    // create the chart...
    JFreeChart chart = ChartFactory.createLineChart3D(// chart title
    m_goal.getMeasure().getName(), // domain axis label
    m_X_AxisLabel, // range axis label
    m_Y_AxisLabel, // data
    linearDataset, // orientation
    PlotOrientation.VERTICAL, // include legend
    false, // tooltips?
    true, // URLs?
    true);
    setupCategoryChart(chart);
    return chart;
}
Also used : JFreeChart(org.jfree.chart.JFreeChart)

Example 43 with JFreeChart

use of org.jfree.chart.JFreeChart in project adempiere by adempiere.

the class WCRP method onEvent.

@Override
public void onEvent(Event event) throws Exception {
    String cmd = event.getTarget().getId();
    if (cmd.equals(ConfirmPanel.A_OK)) {
        Timestamp date = null;
        if (dateFrom.getValue() != null)
            date = (Timestamp) dateFrom.getValue();
        int S_Resource_ID = 0;
        if (resource.getValue() != null)
            S_Resource_ID = ((Integer) resource.getValue()).intValue();
        if (date != null && S_Resource_ID != 0) {
            MResource r = MResource.get(Env.getCtx(), S_Resource_ID);
            int uom_id = r.getResourceType().getC_UOM_ID();
            MUOM uom = MUOM.get(Env.getCtx(), uom_id);
            CategoryDataset dataset = null;
            if (uom.isHour()) {
                dataset = createDataset(date, r);
            } else {
                dataset = createWeightDataset(date, r);
            }
            String title = r.getName() != null ? r.getName() : "";
            title = title + " " + r.getDescription() != null ? r.getDescription() : "";
            JFreeChart jfreechart = createChart(dataset, title, uom);
            renderChart(jfreechart);
        }
    }
    if (cmd.equals(ConfirmPanel.A_CANCEL)) {
        dispose();
    }
}
Also used : MResource(org.compiere.model.MResource) MUOM(org.compiere.model.MUOM) DefaultCategoryDataset(org.jfree.data.category.DefaultCategoryDataset) CategoryDataset(org.jfree.data.category.CategoryDataset) Timestamp(java.sql.Timestamp) JFreeChart(org.jfree.chart.JFreeChart)

Example 44 with JFreeChart

use of org.jfree.chart.JFreeChart in project adempiere by adempiere.

the class WGraph method loadData.

private void loadData() {
    list = builder.loadData();
    if (m_renderChart && m_chartSelection) {
        Toolbar toolbar = new Toolbar();
        panel.appendChild(toolbar);
        int AD_Reference_Value_ID = DB.getSQLValue(null, "SELECT AD_Reference_ID FROM AD_Reference WHERE Name = ?", "PA_Goal ChartType");
        MLookupInfo info = MLookupFactory.getLookup_List(Env.getLanguage(Env.getCtx()), AD_Reference_Value_ID);
        MLookup mLookup = new MLookup(info, 0);
        WTableDirEditor editor = new WTableDirEditor("ChartType", false, false, true, mLookup);
        toolbar.appendChild(editor.getComponent());
        editor.addValueChangeListener(new ValueChangeListener() {

            public void valueChange(ValueChangeEvent evt) {
                Object value = evt.getNewValue();
                if (value == null || value.toString().trim().length() == 0)
                    return;
                JFreeChart chart = null;
                chart = builder.createChart(value.toString());
                if (chart != null)
                    render(chart);
            }
        });
    }
}
Also used : WTableDirEditor(org.adempiere.webui.editor.WTableDirEditor) MLookupInfo(org.compiere.model.MLookupInfo) ValueChangeEvent(org.adempiere.exceptions.ValueChangeEvent) ValueChangeListener(org.adempiere.exceptions.ValueChangeListener) MLookup(org.compiere.model.MLookup) Point(java.awt.Point) JFreeChart(org.jfree.chart.JFreeChart) Toolbar(org.zkoss.zul.Toolbar)

Example 45 with JFreeChart

use of org.jfree.chart.JFreeChart in project adempiere by adempiere.

the class WPerformanceIndicator method init.

/**
	 * 	Init Graph Display
	 *  Kinamo (pelgrim)
	 */
private void init() {
    JFreeChart chart = createChart();
    chart.setBackgroundPaint(null);
    chart.setBorderVisible(true);
    chart.setBorderPaint(Color.LIGHT_GRAY);
    chart.setAntiAlias(true);
    BufferedImage bi = chart.createBufferedImage(200, 120, BufferedImage.TRANSLUCENT, null);
    try {
        byte[] bytes = EncoderUtil.encode(bi, ImageFormat.PNG, true);
        AImage image = new AImage("", bytes);
        Image myImage = new Image();
        myImage.setContent(image);
        appendChild(myImage);
    } catch (Exception e) {
    // TODO: handle exception
    }
    invalidate();
}
Also used : AImage(org.zkoss.image.AImage) AImage(org.zkoss.image.AImage) BufferedImage(java.awt.image.BufferedImage) Image(org.zkoss.zul.Image) JFreeChart(org.jfree.chart.JFreeChart) BufferedImage(java.awt.image.BufferedImage)

Aggregations

JFreeChart (org.jfree.chart.JFreeChart)178 XYPlot (org.jfree.chart.plot.XYPlot)40 NumberAxis (org.jfree.chart.axis.NumberAxis)26 Color (java.awt.Color)22 DateAxis (org.jfree.chart.axis.DateAxis)21 DecimalFormat (java.text.DecimalFormat)18 ChartPanel (org.jfree.chart.ChartPanel)17 XYSeries (org.jfree.data.xy.XYSeries)17 XYSeriesCollection (org.jfree.data.xy.XYSeriesCollection)17 RectangleInsets (org.jfree.ui.RectangleInsets)17 NumberFormat (java.text.NumberFormat)16 CategoryAxis (org.jfree.chart.axis.CategoryAxis)16 CategoryPlot (org.jfree.chart.plot.CategoryPlot)16 DefaultCategoryDataset (org.jfree.data.category.DefaultCategoryDataset)13 TimeSeriesCollection (org.jfree.data.time.TimeSeriesCollection)13 HashMap (java.util.HashMap)12 ValueAxis (org.jfree.chart.axis.ValueAxis)12 XYLineAndShapeRenderer (org.jfree.chart.renderer.xy.XYLineAndShapeRenderer)11 CategoryDataset (org.jfree.data.category.CategoryDataset)11 Paint (java.awt.Paint)10