Example usage for org.jfree.chart ChartFactory createLineChart

List of usage examples for org.jfree.chart ChartFactory createLineChart

Introduction

In this page you can find the example usage for org.jfree.chart ChartFactory createLineChart.

Prototype

public static JFreeChart createLineChart(String title, String categoryAxisLabel, String valueAxisLabel,
        CategoryDataset dataset, PlotOrientation orientation, boolean legend, boolean tooltips, boolean urls) 

Source Link

Document

Creates a line chart with default settings.

Usage

From source file:org.martus.client.swingui.actions.ActionMenuCharts.java

private JFreeChart createCumulativeLineChart(HashMap<String, Integer> counts, String selectedFieldLabel)
        throws Exception {
    DefaultCategoryDataset dataset = createCumulativeChartDataset(counts);

    boolean showLegend = false;
    boolean showTooltips = true;
    boolean showUrls = false;
    JFreeChart lineChart = ChartFactory.createLineChart(getChartTitle(selectedFieldLabel), selectedFieldLabel,
            getYAxisTitle(), dataset, PlotOrientation.VERTICAL, showLegend, showTooltips, showUrls);

    configureBarChartPlot(lineChart);// ww  w  . j  a va  2s.  c o  m

    return lineChart;
}

From source file:org.bhavaya.ui.view.ChartView.java

private JFreeChart createLineChart() {
    JFreeChart chart;/*from  www .  j  a v a  2  s  .  c  o  m*/
    chart = ChartFactory.createLineChart(getName(), getDomainName(), getRangeName(), tableModelDataSet,
            PlotOrientation.HORIZONTAL, true, true, false);
    return chart;
}

From source file:regresiones.EstadisticaDescriptiva.java

private void pintar(JTabbedPane panel1, Double[][] tabla) {
    JPanel panel = new JPanel(new BorderLayout());
    //tabla//from   w  ww.j  a  v a 2  s.co m
    jtable = new JTable();//creamos la tabla a mostrar
    jtable.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(255, 0, 0), 2, true));
    jtable.setFont(new java.awt.Font("Arial", 1, 14));
    jtable.setColumnSelectionAllowed(true);
    jtable.setCursor(new java.awt.Cursor(java.awt.Cursor.N_RESIZE_CURSOR));
    jtable.setInheritsPopupMenu(true);
    jtable.setMinimumSize(new java.awt.Dimension(80, 80));
    String[] titulos = { "i", "Li", "Ls", "Xi", "Fi", "Fa", "Fr", "Fra", "XiFi", "|Xi-X|Fi", "(Xi-X)^2 Fi" };//los titulos de la tabla
    DefaultTableModel TableModel = new DefaultTableModel(formato(tabla), titulos);
    jtable.setModel(TableModel);

    JScrollPane jScrollPane1 = new JScrollPane();
    jScrollPane1.setViewportView(jtable);
    jtable.getColumnModel().getSelectionModel()
            .setSelectionMode(javax.swing.ListSelectionModel.SINGLE_INTERVAL_SELECTION);

    panel.add(jScrollPane1, BorderLayout.CENTER);
    //campos
    JPanel medidas = new JPanel(new GridLayout(0, 6));

    JLabel etiquetaMax = new JLabel("Maximo");
    JTextField cajaMax = new JTextField();
    cajaMax.setText(MAXIMO + "");
    cajaMax.setEditable(false);

    JLabel etiquetaMin = new JLabel("Minimo");
    JTextField cajaMin = new JTextField();
    cajaMin.setText(MINIMO + "");
    cajaMin.setEditable(false);

    JLabel etiquetaN = new JLabel("N");
    JTextField cajaN = new JTextField();
    cajaN.setText(N + "");
    cajaN.setEditable(false);

    JLabel etiquetaRango = new JLabel("Rango");
    JTextField cajaRango = new JTextField();
    cajaRango.setText(MAXIMO - MINIMO + "");
    cajaRango.setEditable(false);

    JLabel etiquetaIntervalos = new JLabel("Intervalos");
    JTextField cajaIntervalos = new JTextField();
    cajaIntervalos.setText(INTERVALOS + "");
    cajaIntervalos.setEditable(false);

    JLabel etiquetaAmp = new JLabel("Amplitud");
    JTextField cajaAmp = new JTextField();
    cajaAmp.setText(AMPLITUD + "");
    cajaAmp.setEditable(false);

    JLabel etiquetaRamp = new JLabel("Rango Ampliado");
    JTextField cajaRamp = new JTextField();
    cajaRamp.setText(RANGOAMPLIADO + "");
    cajaRamp.setEditable(false);

    JLabel etiquetaDifRam = new JLabel("Dif Rangos");
    JTextField cajaDifRam = new JTextField();
    cajaDifRam.setText(DIFERENCIARANGOS + "");
    cajaDifRam.setEditable(false);

    JLabel etiquetaLIPI = new JLabel("LIPI");
    JTextField cajaLIPI = new JTextField();
    cajaLIPI.setText(LIPI + "");
    cajaLIPI.setEditable(false);

    JLabel etiquetaLSUI = new JLabel("LSUI");
    JTextField cajaLSUI = new JTextField();
    cajaLSUI.setText(LSUI + "");
    cajaLSUI.setEditable(false);

    JLabel etiquetaDM = new JLabel("Desv media");
    JTextField cajaDM = new JTextField();
    cajaDM.setText(DM + "");
    cajaDM.setEditable(false);

    JLabel etiquetaV = new JLabel("Varianza");
    JTextField cajaV = new JTextField();
    cajaV.setText(VARIANZA + "");
    cajaV.setEditable(false);

    JLabel etiquetaDE = new JLabel("Desv estandar");
    JTextField cajaDE = new JTextField();
    cajaDE.setText(DE + "");
    cajaDE.setEditable(false);

    JLabel etiquetaMe = new JLabel("Media");
    JTextField cajaMe = new JTextField();
    cajaMe.setText(MEDIA + "");
    cajaMe.setEditable(false);

    JLabel etiquetaMEDIANA = new JLabel("Mediana");
    JTextField cajaMEDIANA = new JTextField();
    cajaMEDIANA.setText(MEDIANA + "");
    cajaMEDIANA.setEditable(false);

    JLabel etiquetaModa = new JLabel("Moda");
    JTextField cajaModa = new JTextField();
    cajaModa.setText(MODA + "");
    cajaModa.setEditable(false);

    JButton boton = new JButton("Exportar a PDF");
    boton.addActionListener(this);

    medidas.add(etiquetaMax);
    medidas.add(cajaMax);
    medidas.add(etiquetaMin);
    medidas.add(cajaMin);
    medidas.add(etiquetaN);
    medidas.add(cajaN);

    medidas.add(etiquetaRango);
    medidas.add(cajaRango); //Jhony        
    medidas.add(etiquetaIntervalos);
    medidas.add(cajaIntervalos);
    medidas.add(etiquetaAmp);
    medidas.add(cajaAmp);
    medidas.add(etiquetaRamp);
    medidas.add(cajaRamp);
    medidas.add(etiquetaDifRam);
    medidas.add(cajaDifRam);
    medidas.add(etiquetaLIPI); //lipi
    medidas.add(cajaLIPI);

    medidas.add(etiquetaLSUI);
    medidas.add(cajaLSUI);
    medidas.add(etiquetaDM); //DESVIACION MEDIA
    medidas.add(cajaDM);
    medidas.add(etiquetaV); //VARIANZA
    medidas.add(cajaV);
    medidas.add(etiquetaDE); //DESVIACION ESTANDAR
    medidas.add(cajaDE);
    medidas.add(etiquetaMe); //MEDIA
    medidas.add(cajaMe);
    medidas.add(etiquetaMEDIANA); // mediana
    medidas.add(cajaMEDIANA);
    medidas.add(etiquetaModa); //moda
    medidas.add(cajaModa);
    medidas.add(boton);
    //SECCION DE GRAFICAS

    JFreeChart Grafica;
    DefaultCategoryDataset Datos = new DefaultCategoryDataset();
    //Buscar las pociciones de  LI       LS      Fa
    //                         0,1      0,2     0,5
    //agregar los valores a la grafica
    for (int i = 0; i < INTERVALOS; i++) {

        Datos.addValue(tabla[i][3], "frecuencia", tabla[i][1] + " - " + tabla[i][2]);
    }

    Grafica = ChartFactory.createLineChart("Histograma", "Frecuencia", "Li Ls", Datos, PlotOrientation.VERTICAL,
            true, true, false);

    ChartPanel p = new ChartPanel(Grafica);

    // termina seccion de grafica

    panel.add(medidas, BorderLayout.SOUTH);
    //panel.add(jScrollPane1, BorderLayout.CENTER); 
    panel1.addTab("Resultados", panel);
    panel1.addTab("Grafica", p);
}

From source file:UserInterface.TMAnalystRole.TMAnaylstWorkAreaJPanel.java

private void generateGraph(Train selectedTrain) {

    ArrayList<TrainOffered> selectedTrainOfferedListWEEKDAYS = new ArrayList<>();
    ArrayList<TrainOffered> selectedTrainOfferedListWEEKENDS = new ArrayList<>();

    int days = (int) spnrRecord.getValue();
    Date today = new Date();
    Date olderThanToday = new Date();
    olderThanToday.setTime(today.getTime() + (long) (-days) * 1000 * 60 * 60 * 24);
    long todayDate = (today.getTime()) / (1000 * 60 * 60 * 24);
    long olderDate = (olderThanToday.getTime()) / (1000 * 60 * 60 * 24);

    for (TrainOffered selectedTrainOffered : enterprise.getTrainsOfferedHistory().getTrainsOffered()) {
        if (selectedTrainOffered.getTrain().equals(selectedTrain)) {
            long selectedDate = (selectedTrainOffered.getDayOffered().getTime()) / (1000 * 60 * 60 * 24);
            if (selectedDate >= olderDate && selectedDate <= todayDate) {
                Calendar date = Calendar.getInstance();
                date.setTime(selectedTrainOffered.getDayOffered());
                if ((date.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY)
                        || ((date.get(Calendar.DAY_OF_WEEK) == Calendar.SATURDAY))) {
                    if (!selectedTrainOfferedListWEEKENDS.contains(selectedTrainOffered)) {
                        selectedTrainOfferedListWEEKENDS.add(selectedTrainOffered);
                    }//from  w ww . j ava2 s .  c  o m
                } else {
                    if (!selectedTrainOfferedListWEEKDAYS.contains(selectedTrainOffered)) {
                        selectedTrainOfferedListWEEKDAYS.add(selectedTrainOffered);
                    }
                }
            }
        }
    }

    Map<TimeSlot.TimeSlotRange, Integer> weekendData = new HashMap<TimeSlot.TimeSlotRange, Integer>();

    for (TrainOffered selectedTrainOfferedOnWeekend : selectedTrainOfferedListWEEKENDS) {
        for (TrainStatus rt : selectedTrainOfferedOnWeekend.getRunningTrains()) {
            if (weekendData.containsKey(rt.getTrainSchedule().getTimeSlot())) {
                Integer previousValue = weekendData.get(rt.getTrainSchedule().getTimeSlot());
                weekendData.put(rt.getTrainSchedule().getTimeSlot(), previousValue + rt.getRunningCapacity());
            } else {
                weekendData.put(rt.getTrainSchedule().getTimeSlot(), rt.getRunningCapacity());
            }
        }
    }

    ArrayList<Integer> sortedWeekendData = new ArrayList<>();
    if (weekendData.size() > 0) {
        for (TimeSlot.TimeSlotRange tsr : TimeSlot.TimeSlotRange.values()) {
            sortedWeekendData.add(weekendData.get(tsr));
        }
    }

    Map<TimeSlot.TimeSlotRange, Integer> weekdayData = new HashMap<>();

    for (TrainOffered selectedTrainOfferedOnWeekDays : selectedTrainOfferedListWEEKDAYS) {
        for (TrainStatus rt : selectedTrainOfferedOnWeekDays.getRunningTrains()) {
            if (weekdayData.containsKey(rt.getTrainSchedule().getTimeSlot())) {
                Integer previousValue = weekdayData.get(rt.getTrainSchedule().getTimeSlot());
                weekdayData.put(rt.getTrainSchedule().getTimeSlot(), previousValue + rt.getRunningCapacity());
            } else {
                weekdayData.put(rt.getTrainSchedule().getTimeSlot(), rt.getRunningCapacity());
            }
        }
    }

    ArrayList<Integer> sortedWeekDayDataList = new ArrayList<>();
    if (weekdayData.size() > 0) {
        for (TimeSlot.TimeSlotRange tsr : TimeSlot.TimeSlotRange.values()) {
            sortedWeekDayDataList.add(weekdayData.get(tsr));
        }
    }

    CategoryDataset dataset;
    String series1 = "Weekdays";
    String series2 = "Weekends";
    String series3 = "Maximum Capcity";

    DefaultCategoryDataset dataset1 = new DefaultCategoryDataset();

    for (int i = 0; i < sortedWeekendData.size(); i++) {
        dataset1.addValue(Math.round(sortedWeekendData.get(i) / selectedTrainOfferedListWEEKENDS.size()),
                series2, TimeSlot.TimeSlotRange.values()[i].getValue());
    }

    for (int i = 0; i < sortedWeekDayDataList.size(); i++) {
        // System.out.println("Key = " + entry.getKey().getValue() + ", Value = " + Math.round(entry.getValue()/selectedTrainOfferedListWEEKENDS.size()));
        dataset1.addValue(Math.round(sortedWeekDayDataList.get(i) / selectedTrainOfferedListWEEKDAYS.size()),
                series1, TimeSlot.TimeSlotRange.values()[i].getValue());
    }

    for (int i = 0; i < 15; i++) {
        // System.out.println("Key = " + entry.getKey().getValue() + ", Value = " + Math.round(entry.getValue()/selectedTrainOfferedListWEEKENDS.size()));
        dataset1.addValue(selectedTrain.getTrainCapacity(), series3,
                TimeSlot.TimeSlotRange.values()[i].getValue());
    }

    dataset = dataset1;

    final JFreeChart chart = ChartFactory.createLineChart(
            "Average Congestion of Train : " + selectedTrain.getTrainName(), // chart title
            "Time Slot", // domain axis label
            "Congestion Level", // range axis label
            dataset, // data
            PlotOrientation.VERTICAL, // orientation
            true, // include legend
            true, // tooltips
            false // urls
    );

    chart.setBackgroundPaint(Color.white);

    final CategoryPlot plot = (CategoryPlot) chart.getPlot();
    plot.setBackgroundPaint(Color.lightGray);
    plot.setRangeGridlinePaint(Color.white);

    ChartFrame chartPanel = new ChartFrame("Line Chart of Train", chart);
    chartPanel.setSize(this.getWidth(), this.getHeight() + 200);
    chartPanel.setVisible(true);

}

From source file:org.pau.assetmanager.viewmodel.MonthlyReportViewModel.java

/**
 * Generates the image of a time series in which there are four series --
 * Income: the sum of amount of income annotations for a given month in a
 * year -- Expenses: the sum of amount of expenses annotations for a given
 * month in a year -- Monthly Total: the *difference* between Income and
 * Expenses (Monthly Total := Income - Expenses) -- Cumulative: the
 * cumulative sum over time of 'Monthly Total'
 * /*from  w  w w .j  av  a 2  s  .co m*/
 * @return the relative random URL generated
 */
@DependsOn({ "selectedBook", "clientType", "monthlyReportYear" })
public String getMonthlyReportSimpleChartURL() {
    if (bookSelection.getSelectedBook() == null) {
        return "";
    }
    List<Annotation> anotations = getAnnotationsInAscendingDateOrder(Optional.of(monthlyReportYear));
    CategoryDataset categoryModel = ChartDataModel.getIncomeExpensesSimpleOverTime(anotations,
            monthlyReportYear, bookSelection.getSelectedBook());
    JFreeChart jfchart = ChartFactory.createLineChart("Ingresos vs. Gastos", "Fecha", "Euros", categoryModel,
            PlotOrientation.VERTICAL, true, true, false);
    PrepareChart.prepareSimpleJFreeChart(jfchart);
    return ResourceImageGenerator.getFunction().apply(jfchart);
}

From source file:org.talend.dataprofiler.chart.ChartDecorator.java

/**
 * Decorate the benford law chart. in this method the line chart will be overlay on top of bar chart.
 * /*from w  ww  . j  a v a2 s  .  c o  m*/
 * @param dataset
 * @param barChart
 * @param title
 * @param categoryAxisLabel
 * @param dotChartLabels
 * @param formalValues
 * @return JFreeChart
 */
@SuppressWarnings("deprecation")
public static JFreeChart decorateBenfordLawChartByKCD(CategoryDataset dataset, Object customerDataset,
        JFreeChart barChart, String title, String categoryAxisLabel, List<String> dotChartLabels,
        double[] formalValues) {
    CategoryPlot barplot = barChart.getCategoryPlot();
    decorateBarChart(barChart, new BenfordLawLineAndShapeRenderer());
    // display percentage on top of the bar
    DecimalFormat df = new DecimalFormat(PERCENT_FORMAT);
    barplot.getRenderer().setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator("{2}", df)); //$NON-NLS-1$
    barplot.getRenderer().setBasePositiveItemLabelPosition(
            new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12, TextAnchor.BASELINE_CENTER));
    // set the display of Y axis
    NumberAxis numAxis = (NumberAxis) barplot.getRangeAxis();
    numAxis.setNumberFormatOverride(df);

    CategoryDataset lineDataset = getLineDataset(dotChartLabels, formalValues);
    JFreeChart lineChart = ChartFactory.createLineChart(null, title, categoryAxisLabel, lineDataset,
            PlotOrientation.VERTICAL, false, false, false);
    CategoryPlot plot = lineChart.getCategoryPlot();
    if (customerDataset != null) {
        barplot.setDataset(2, new EncapsulationCumstomerDataset(dataset, customerDataset));
    }
    // show the value on the right axis of the chart(keep the comment)
    // NumberAxis numberaxis = new NumberAxis(DefaultMessagesImpl.getString("TopChartFactory.Value"));
    // plot.setRangeAxis(10, numberaxis);

    NumberAxis vn = (NumberAxis) plot.getRangeAxis();
    vn.setNumberFormatOverride(df);
    // set points format
    LineAndShapeRenderer renderer = (LineAndShapeRenderer) plot.getRenderer();
    renderer.setPaint(COLOR_LIST.get(1));
    renderer.setSeriesShape(1, new Rectangle2D.Double(-1.5, -1.5, 3, 3));
    renderer.setShapesVisible(true); // show the point shape
    renderer.setBaseLinesVisible(false);// do not show the line

    // add the bar chart into the line chart
    CategoryItemRenderer barChartRender = barplot.getRenderer();
    barplot.setDataset(0, lineDataset);
    barplot.setRenderer(0, plot.getRenderer());
    barplot.setDataset(1, dataset);
    barplot.setRenderer(1, barChartRender);
    return barChart;
}

From source file:charts.Chart.java

public static void LineChart(double[][] data, String title_validation, String title, String x_axis_label,
        String y_axis_label) {/* www .  ja  v  a  2 s . co  m*/

    DefaultCategoryDataset dataset = new DefaultCategoryDataset();
    for (int i = 0; i < data.length; i++) {
        dataset.addValue(data[i][1], title_validation, String.valueOf(data[i][2]));
    }
    JFrame chartwindow = new JFrame(title);
    JFreeChart jfreechart = ChartFactory.createLineChart(title, x_axis_label, y_axis_label, dataset,
            PlotOrientation.VERTICAL, true, true, false);

    CategoryPlot categoryplot = (CategoryPlot) jfreechart.getPlot();
    categoryplot.setBackgroundPaint(Color.white);
    categoryplot.setRangeGridlinePaint(Color.black);
    NumberAxis numberaxis = (NumberAxis) categoryplot.getRangeAxis();
    numberaxis.setStandardTickUnits(NumberAxis.createStandardTickUnits());

    LineAndShapeRenderer lineandshaperenderer = (LineAndShapeRenderer) categoryplot.getRenderer();
    lineandshaperenderer.setShapesVisible(true);
    lineandshaperenderer.setDrawOutlines(true);
    lineandshaperenderer.setUseFillPaint(true);
    lineandshaperenderer.setFillPaint(Color.white);

    JPanel jpanel = new ChartPanel(jfreechart);
    jpanel.setPreferredSize(new Dimension(defaultwidth, defaultheight));
    chartwindow.setContentPane(jpanel);
    chartwindow.pack();
    RefineryUtilities.centerFrameOnScreen(chartwindow);
    chartwindow.setVisible(true);
}

From source file:org.adempiere.apps.graph.ChartBuilder.java

private JFreeChart createLineChart() {
    // create the chart...
    JFreeChart chart = ChartFactory.createLineChart(chartModel.get_Translation(MChart.COLUMNNAME_Name), // chart title
            chartModel.get_Translation(MChart.COLUMNNAME_DomainLabel), // domain axis label
            chartModel.get_Translation(MChart.COLUMNNAME_RangeLabel), // range axis label
            getCategoryDataset(), // data
            X_AD_Chart.CHARTORIENTATION_Horizontal.equals(chartModel.getChartOrientation())
                    ? PlotOrientation.HORIZONTAL
                    : PlotOrientation.VERTICAL, // orientation
            chartModel.isDisplayLegend(), // include legend
            true, // tooltips?
            true // URLs?
    );/* ww  w .j ava 2s  .c o m*/

    setupCategoryChart(chart);
    return chart;
}

From source file:org.sakaiproject.sitestats.impl.chart.ChartServiceImpl.java

private byte[] generateLineChart(String siteId, CategoryDataset dataset, int width, int height,
        boolean render3d, float transparency, boolean itemLabelsVisible, boolean smallFontInDomainAxis) {
    JFreeChart chart = null;/*from   w ww  . j a v  a 2 s  .c o m*/
    if (render3d)
        chart = ChartFactory.createLineChart3D(null, null, null, dataset, PlotOrientation.VERTICAL, true, false,
                false);
    else
        chart = ChartFactory.createLineChart(null, null, null, dataset, PlotOrientation.VERTICAL, true, false,
                false);
    CategoryPlot plot = (CategoryPlot) chart.getPlot();

    // set transparency
    plot.setForegroundAlpha(transparency);

    // set background
    chart.setBackgroundPaint(parseColor(M_sm.getChartBackgroundColor()));

    // set chart border
    chart.setPadding(new RectangleInsets(10, 5, 5, 5));
    chart.setBorderVisible(true);
    chart.setBorderPaint(parseColor("#cccccc"));

    // set antialias
    chart.setAntiAlias(true);

    // set domain axis font size
    if (smallFontInDomainAxis && !canUseNormalFontSize(width)) {
        plot.getDomainAxis().setTickLabelFont(new Font("SansSerif", Font.PLAIN, 8));
        plot.getDomainAxis().setCategoryMargin(0.05);
    }

    // set outline
    LineAndShapeRenderer renderer = (LineAndShapeRenderer) plot.getRenderer();
    renderer.setDrawOutlines(true);

    // item labels
    if (itemLabelsVisible) {
        plot.getRangeAxis().setUpperMargin(0.2);
        renderer.setItemLabelGenerator(new StandardCategoryItemLabelGenerator() {
            private static final long serialVersionUID = 1L;

            @Override
            public String generateLabel(CategoryDataset dataset, int row, int column) {
                Number n = dataset.getValue(row, column);
                if (n.intValue() != 0)
                    //return n.intValue()+"";
                    return n.toString();
                return "";
            }
        });
        renderer.setItemLabelFont(new Font("SansSerif", Font.PLAIN, 8));
        renderer.setItemLabelsVisible(true);
    }

    BufferedImage img = chart.createBufferedImage(width, height);
    final ByteArrayOutputStream out = new ByteArrayOutputStream();
    try {
        ImageIO.write(img, "png", out);
    } catch (IOException e) {
        LOG.warn("Error occurred while generating SiteStats chart image data", e);
    }
    return out.toByteArray();
}

From source file:org.pentaho.di.ui.spoon.trans.TransPerfDelegate.java

private void updateCanvas() {
    Rectangle bounds = canvas.getBounds();
    if (bounds.width <= 0 || bounds.height <= 0) {
        return;//  w w w.  j  av a 2s  . c  o  m
    }

    // The list of snapshots : convert to JFreeChart dataset
    //
    DefaultCategoryDataset dataset = new DefaultCategoryDataset();

    String[] selectedSteps = stepsList.getSelection();
    if (selectedSteps == null || selectedSteps.length == 0) {
        selectedSteps = new String[] { steps[0], }; // first step
        stepsList.select(0);
    }
    int[] dataIndices = dataList.getSelectionIndices();
    if (dataIndices == null || dataIndices.length == 0) {
        dataIndices = new int[] { DATA_CHOICE_WRITTEN, };
        dataList.select(0);
    }

    boolean multiStep = stepsList.getSelectionCount() > 1;
    boolean multiData = dataList.getSelectionCount() > 1;
    boolean calcMoving = !multiStep && !multiData; // A single metric shown for a single step
    List<Double> movingList = new ArrayList<Double>();
    int movingSize = 10;
    double movingTotal = 0;
    int totalTimeInSeconds = 0;

    for (int t = 0; t < selectedSteps.length; t++) {

        String stepNameCopy = selectedSteps[t];

        List<StepPerformanceSnapShot> snapShotList = stepPerformanceSnapShots.get(stepNameCopy);
        if (snapShotList != null && snapShotList.size() > 1) {
            totalTimeInSeconds = (int) Math
                    .round(((double) (snapShotList.get(snapShotList.size() - 1).getDate().getTime()
                            - snapShotList.get(0).getDate().getTime())) / 1000);
            for (int i = 0; i < snapShotList.size(); i++) {
                StepPerformanceSnapShot snapShot = snapShotList.get(i);
                if (snapShot.getTimeDifference() != 0) {

                    double factor = (double) 1000 / (double) snapShot.getTimeDifference();

                    for (int d = 0; d < dataIndices.length; d++) {

                        String dataType;
                        if (multiStep) {
                            dataType = stepNameCopy;
                        } else {
                            dataType = dataChoices[dataIndices[d]];
                        }
                        String xLabel = Integer.toString(Math.round(i * timeDifference / 1000));
                        Double metric = null;
                        switch (dataIndices[d]) {
                        case DATA_CHOICE_INPUT:
                            metric = snapShot.getLinesInput() * factor;
                            break;
                        case DATA_CHOICE_OUTPUT:
                            metric = snapShot.getLinesOutput() * factor;
                            break;
                        case DATA_CHOICE_READ:
                            metric = snapShot.getLinesRead() * factor;
                            break;
                        case DATA_CHOICE_WRITTEN:
                            metric = snapShot.getLinesWritten() * factor;
                            break;
                        case DATA_CHOICE_UPDATED:
                            metric = snapShot.getLinesUpdated() * factor;
                            break;
                        case DATA_CHOICE_REJECTED:
                            metric = snapShot.getLinesRejected() * factor;
                            break;
                        case DATA_CHOICE_INPUT_BUFFER_SIZE:
                            metric = (double) snapShot.getInputBufferSize();
                            break;
                        case DATA_CHOICE_OUTPUT_BUFFER_SIZE:
                            metric = (double) snapShot.getOutputBufferSize();
                            break;
                        default:
                            break;
                        }
                        if (metric != null) {
                            dataset.addValue(metric, dataType, xLabel);

                            if (calcMoving) {
                                movingTotal += metric;
                                movingList.add(metric);
                                if (movingList.size() > movingSize) {
                                    movingTotal -= movingList.get(0);
                                    movingList.remove(0);
                                }
                                double movingAverage = movingTotal / movingList.size();
                                dataset.addValue(movingAverage, dataType + "(Avg)", xLabel);
                                // System.out.println("moving average = "+movingAverage+", movingTotal="+movingTotal+", m");
                            }
                        }
                    }
                }
            }
        }
    }
    String chartTitle = title;
    if (multiStep) {
        chartTitle += " (" + dataChoices[dataIndices[0]] + ")";
    } else {
        chartTitle += " (" + selectedSteps[0] + ")";
    }
    final JFreeChart chart = ChartFactory.createLineChart(chartTitle, // chart title
            BaseMessages.getString(PKG, "StepPerformanceSnapShotDialog.TimeInSeconds.Label",
                    Integer.toString(totalTimeInSeconds), Long.toString(timeDifference)), // domain axis label
            BaseMessages.getString(PKG, "StepPerformanceSnapShotDialog.RowsPerSecond.Label"), // range axis label
            dataset, // data
            PlotOrientation.VERTICAL, // orientation
            true, // include legend
            true, // tooltips
            false); // urls       
    chart.setBackgroundPaint(Color.white);
    TextTitle title = new TextTitle(chartTitle);
    // title.setExpandToFitSpace(true);
    // org.eclipse.swt.graphics.Color pentahoColor = GUIResource.getInstance().getColorPentaho();
    // java.awt.Color color = new java.awt.Color(pentahoColor.getRed(), pentahoColor.getGreen(),pentahoColor.getBlue());
    // title.setBackgroundPaint(color);
    title.setFont(new java.awt.Font("SansSerif", java.awt.Font.BOLD, 12));
    chart.setTitle(title);
    CategoryPlot plot = (CategoryPlot) chart.getPlot();
    plot.setBackgroundPaint(Color.white);
    plot.setForegroundAlpha(0.5f);
    plot.setRangeGridlinesVisible(true);

    NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());

    CategoryAxis domainAxis = plot.getDomainAxis();
    domainAxis.setTickLabelsVisible(false);

    // Customize the renderer...
    //
    LineAndShapeRenderer renderer = (LineAndShapeRenderer) plot.getRenderer();
    renderer.setBaseShapesVisible(true);
    renderer.setDrawOutlines(true);
    renderer.setUseFillPaint(true);
    renderer.setBaseFillPaint(Color.white);
    renderer.setSeriesStroke(0, new BasicStroke(1.5f));
    renderer.setSeriesOutlineStroke(0, new BasicStroke(1.5f));
    renderer.setSeriesStroke(1, new BasicStroke(2.5f));
    renderer.setSeriesOutlineStroke(1, new BasicStroke(2.5f));
    renderer.setSeriesShape(0, new Ellipse2D.Double(-3.0, -3.0, 6.0, 6.0));

    BufferedImage bufferedImage = chart.createBufferedImage(bounds.width, bounds.height,
            BufferedImage.TYPE_INT_RGB, null);
    ImageData imageData = ImageUtil.convertToSWT(bufferedImage);

    // dispose previous image...
    //
    if (image != null) {
        image.dispose();
    }
    image = new Image(transGraph.getDisplay(), imageData);

    // Draw the image on the canvas...
    //
    canvas.redraw();
}