com.jtk.pengelolaanujian.view.dashboard.PipePanelSample.java Source code

Java tutorial

Introduction

Here is the source code for com.jtk.pengelolaanujian.view.dashboard.PipePanelSample.java

Source

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.jtk.pengelolaanujian.view.dashboard;

/**
 *
 * @author pahlevi
 */
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import javax.swing.JPanel;
import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartPanel;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.axis.CategoryAxis;
import org.jfree.chart.axis.CategoryLabelPositions;
import org.jfree.chart.plot.CategoryPlot;
import org.jfree.chart.plot.PlotOrientation;
import org.jfree.chart.renderer.category.BarRenderer;
import org.jfree.chart.renderer.category.CategoryItemRenderer;
import org.jfree.data.category.DefaultCategoryDataset;

public class PipePanelSample extends javax.swing.JPanel {

    /**
     * Creates new form PipePanelSample
     */
    private JFreeChart barchart;
    private ChartPanel panel;

    public PipePanelSample() {
        panel = createChart(createData());
        setLayout(new BorderLayout());
        add(panel, BorderLayout.CENTER);
    }

    private DefaultCategoryDataset createData() {
        DefaultCategoryDataset data = new DefaultCategoryDataset();
        data.addValue(20, "Terlambat Upload Soal", "Upload Soal");
        data.addValue(13, "Terlambat Upload VNV", "Upload VNV");
        data.addValue(3, "Terlambat Cetak Soal", "Cetak Soal");
        data.addValue(18, "Terlambat Upload Nilai", "Upload Nilai");
        return data;
    }

    private ChartPanel createChart(DefaultCategoryDataset data) {
        barchart = ChartFactory.createBarChart3D("Data Keterlambatan pengelolaan Soal Ujian", "Aktifitas",
                "Jumlah Keterlambatan", data, PlotOrientation.VERTICAL, true, true, false);
        barchart.setBackgroundPaint(new Color(135, 206, 250));
        CategoryPlot plot = (CategoryPlot) barchart.getPlot();
        plot.setNoDataMessage("Data Tidak ada");
        CategoryAxis axis = plot.getDomainAxis();
        axis.setCategoryLabelPositions(CategoryLabelPositions.STANDARD);
        CategoryItemRenderer renderer = plot.getRenderer();
        renderer.setBaseItemLabelsVisible(true);
        BarRenderer barRenderer = (BarRenderer) renderer;
        barRenderer.setItemMargin(0.1D);
        barRenderer.setDrawBarOutline(true);
        return new ChartPanel(barchart);
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGap(0,
                323, Short.MAX_VALUE));
        layout.setVerticalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 252,
                Short.MAX_VALUE));
    }// </editor-fold>//GEN-END:initComponents

    // Variables declaration - do not modify//GEN-BEGIN:variables
    // End of variables declaration//GEN-END:variables
}