use of org.jfree.chart.labels.StandardPieSectionLabelGenerator in project DevKits by qmjy.
the class FileStorePanel method configurePlot.
private static void configurePlot(JFreeChart chart) {
PiePlot plot = (PiePlot) chart.getPlot();
plot.setSectionPaint(USED, Color.red);
plot.setSectionPaint(AVAILABLE, Color.green);
plot.setExplodePercent(USED, 0.10);
plot.setSimpleLabels(true);
PieSectionLabelGenerator labelGenerator = new StandardPieSectionLabelGenerator("{0}: {1} ({2})", new DecimalFormat("0"), new DecimalFormat("0%"));
plot.setLabelGenerator(labelGenerator);
}
use of org.jfree.chart.labels.StandardPieSectionLabelGenerator in project blueseer by blueseerERP.
the class ExpenseBrowse method chartExpense.
public void chartExpense() {
try {
Connection con = DriverManager.getConnection(url + db, user, pass);
Statement st = con.createStatement();
ResultSet res = null;
try {
java.util.Date now = new java.util.Date();
DateFormat dfdate = new SimpleDateFormat("yyyy-MM-dd");
Calendar cal = new GregorianCalendar();
cal.set(Calendar.DAY_OF_YEAR, 1);
java.util.Date firstday = cal.getTime();
res = st.executeQuery("select ap_vend, sum(ap_amt) as 'sum' from ap_mstr " + // " inner join vd_mstr on vd_addr = ap_vend " +
" inner join vod_mstr on vod_id = ap_nbr " + " where ap_vend >= " + "'" + ddfromvend.getSelectedItem().toString() + "'" + " and ap_vend <= " + "'" + ddtovend.getSelectedItem().toString() + "'" + " and ap_effdate >= " + "'" + dfdate.format(dcFrom.getDate()) + "'" + " and ap_effdate <= " + "'" + dfdate.format(dcTo.getDate()) + "'" + " and ap_type = 'E' " + " and ap_status = 'c' " + " group by ap_vend " + ";");
DefaultPieDataset dataset = new DefaultPieDataset();
String vend = "";
while (res.next()) {
if (res.getString("ap_vend") == null || res.getString("ap_vend").isEmpty()) {
vend = "Unassigned";
} else {
vend = res.getString("ap_vend");
}
Double amt = res.getDouble("sum");
if (amt < 0) {
amt = amt * -1;
}
dataset.setValue(vend, amt);
}
JFreeChart chart = ChartFactory.createPieChart(getTitleTag(5027), dataset, false, false, false);
PiePlot plot = (PiePlot) chart.getPlot();
// plot.setSectionPaint(KEY1, Color.green);
// plot.setSectionPaint(KEY2, Color.red);
// plot.setExplodePercent(KEY1, 0.10);
// plot.setSimpleLabels(true);
PieSectionLabelGenerator gen = new StandardPieSectionLabelGenerator("{0}: {1} ({2})", NumberFormat.getCurrencyInstance(), new DecimalFormat("0.00%"));
plot.setLabelGenerator(gen);
try {
ChartUtilities.saveChartAsJPEG(new File(chartfilepath), chart, (int) (this.getWidth() / 2), (int) (this.getHeight() / 1.2));
} catch (IOException e) {
MainFrame.bslog(e);
}
ImageIcon myicon = new ImageIcon(chartfilepath);
myicon.getImage().flush();
this.pielabel.setIcon(myicon);
this.repaint();
// bsmf.MainFrame.show("your chart is complete...go to chartview");
} catch (SQLException s) {
MainFrame.bslog(s);
bsmf.MainFrame.show(getMessageTag(1016, Thread.currentThread().getStackTrace()[1].getMethodName()));
} finally {
if (res != null) {
res.close();
}
if (st != null) {
st.close();
}
con.close();
}
} catch (Exception e) {
MainFrame.bslog(e);
}
}
use of org.jfree.chart.labels.StandardPieSectionLabelGenerator in project blueseer by blueseerERP.
the class GLAcctBalRpt3 method chartExpAndInc.
public void chartExpAndInc() {
try {
Connection con = DriverManager.getConnection(url + db, user, pass);
Statement st = con.createStatement();
ResultSet res = null;
try {
java.util.Date now = new java.util.Date();
DateFormat dfdate = new SimpleDateFormat("yyyy-MM-dd");
Calendar cal = new GregorianCalendar();
cal.set(Calendar.DAY_OF_YEAR, 1);
java.util.Date firstday = cal.getTime();
res = st.executeQuery("select ac_type, sum(glh_base_amt) as 'sum' from gl_hist inner join ac_mstr on ac_id = glh_acct " + " where glh_effdate >= " + "'" + dfdate.format(firstday) + "'" + " AND glh_effdate <= " + "'" + dfdate.format(now) + "'" + " AND glh_site = " + "'" + ddsite.getSelectedItem().toString() + "'" + " AND ( ac_type = 'E' or ac_type = 'I' ) " + " group by ac_type ;");
DefaultPieDataset dataset = new DefaultPieDataset();
String acct = "";
while (res.next()) {
if (res.getString("ac_type") == null || res.getString("ac_type").isEmpty()) {
acct = "Unassigned";
} else {
acct = res.getString("ac_type");
}
Double amt = res.getDouble("sum");
if (amt < 0) {
amt = amt * -1;
}
dataset.setValue(acct, amt);
}
JFreeChart chart = ChartFactory.createPieChart(getTitleTag(5026), dataset, true, true, false);
PiePlot plot = (PiePlot) chart.getPlot();
// plot.setSectionPaint(KEY1, Color.green);
// plot.setSectionPaint(KEY2, Color.red);
// plot.setExplodePercent(KEY1, 0.10);
// plot.setSimpleLabels(true);
PieSectionLabelGenerator gen = new StandardPieSectionLabelGenerator("{0}: {1} ({2})", NumberFormat.getCurrencyInstance(), new DecimalFormat("0.00%"));
plot.setLabelGenerator(gen);
try {
ChartUtilities.saveChartAsJPEG(new File(chartfilepath), chart, (int) (this.getWidth() / 2.5), (int) (this.getHeight() / 2.5));
} catch (IOException e) {
MainFrame.bslog(e);
}
ImageIcon myicon = new ImageIcon(chartfilepath);
myicon.getImage().flush();
this.pielabel.setIcon(myicon);
this.repaint();
// bsmf.MainFrame.show("your chart is complete...go to chartview");
} catch (SQLException s) {
MainFrame.bslog(s);
bsmf.MainFrame.show(getMessageTag(1016, Thread.currentThread().getStackTrace()[1].getMethodName()));
} finally {
if (res != null) {
res.close();
}
if (st != null) {
st.close();
}
con.close();
}
} catch (Exception e) {
MainFrame.bslog(e);
}
}
use of org.jfree.chart.labels.StandardPieSectionLabelGenerator in project blueseer by blueseerERP.
the class ChartView method piechart_expensebyaccount.
// finance
public void piechart_expensebyaccount() {
try {
cleanUpOldChartFile();
Connection con = DriverManager.getConnection(url + db, user, pass);
Statement st = con.createStatement();
ResultSet res = null;
try {
DateFormat dfdate = new SimpleDateFormat("yyyy-MM-dd");
res = st.executeQuery("select glh_acct, ac_desc, sum(glh_amt) as 'sum' from gl_hist inner join ac_mstr on ac_id = glh_acct " + " where glh_effdate >= " + "'" + dfdate.format(dcFrom.getDate()) + "'" + " AND glh_effdate <= " + "'" + dfdate.format(dcTo.getDate()) + "'" + " AND ac_type = 'E' " + " group by glh_acct, ac_desc order by sum desc limit 10 ;");
DefaultPieDataset dataset = new DefaultPieDataset();
String acct = "";
while (res.next()) {
if (res.getString("glh_acct") == null || res.getString("glh_acct").isEmpty()) {
acct = "Unassigned";
} else {
acct = res.getString("ac_desc");
}
Double amt = res.getDouble("sum");
dataset.setValue(acct, amt);
}
JFreeChart chart = ChartFactory.createPieChart(getTitleTag(5000), dataset, true, true, false);
PiePlot plot = (PiePlot) chart.getPlot();
PieSectionLabelGenerator gen = new StandardPieSectionLabelGenerator(("{1} ({2})"), NumberFormat.getCurrencyInstance(), new DecimalFormat("0.00%"));
plot.setLabelGenerator(gen);
try {
ChartUtilities.saveChartAsJPEG(new File(chartfilepath), chart, 900, this.getHeight() / 2);
} catch (IOException e) {
MainFrame.bslog(e);
}
ImageIcon myicon = new ImageIcon(chartfilepath);
myicon.getImage().flush();
this.chartlabel.setIcon(myicon);
ChartPanel.setVisible(true);
this.repaint();
} catch (SQLException s) {
MainFrame.bslog(s);
} finally {
if (res != null)
res.close();
if (st != null)
st.close();
con.close();
}
} catch (Exception e) {
MainFrame.bslog(e);
}
}
use of org.jfree.chart.labels.StandardPieSectionLabelGenerator in project blueseer by blueseerERP.
the class ChartView method piechart_custAR.
public void piechart_custAR() {
try {
cleanUpOldChartFile();
Connection con = DriverManager.getConnection(url + db, user, pass);
Statement st = con.createStatement();
ResultSet res = null;
try {
DecimalFormat df = new DecimalFormat("$ #,##0.00", new DecimalFormatSymbols(Locale.getDefault()));
DateFormat dfdate = new SimpleDateFormat("yyyy-MM-dd");
res = st.executeQuery("select ar_cust, sum(ar_amt) as 'sum' from ar_mstr " + " where ar_effdate >= " + "'" + dfdate.format(dcFrom.getDate()) + "'" + " AND ar_effdate <= " + "'" + dfdate.format(dcTo.getDate()) + "'" + " AND ar_type = 'I' " + " AND ar_status = 'o' " + " group by ar_cust order by sum desc limit 10 ;");
DefaultPieDataset dataset = new DefaultPieDataset();
String acct = "";
double tot = 0.00;
while (res.next()) {
if (res.getString("ar_cust") == null || res.getString("ar_cust").isEmpty()) {
acct = "Unassigned";
} else {
acct = res.getString("ar_cust");
}
double amt = res.getDouble("sum");
tot += amt;
dataset.setValue(acct, amt);
}
JFreeChart chart = ChartFactory.createPieChart(getTitleTag(5010) + String.valueOf(currformatDouble(tot)), dataset, true, true, false);
PiePlot plot = (PiePlot) chart.getPlot();
PieSectionLabelGenerator gen = new StandardPieSectionLabelGenerator(("{1} ({2})"), NumberFormat.getCurrencyInstance(), new DecimalFormat("0.00%"));
plot.setLabelGenerator(gen);
try {
ChartUtilities.saveChartAsJPEG(new File(chartfilepath), chart, 900, this.getHeight() / 2);
} catch (IOException e) {
MainFrame.bslog(e);
}
ImageIcon myicon = new ImageIcon(chartfilepath);
myicon.getImage().flush();
this.chartlabel.setIcon(myicon);
ChartPanel.setVisible(true);
this.repaint();
} catch (SQLException s) {
MainFrame.bslog(s);
} finally {
if (res != null)
res.close();
if (st != null)
st.close();
con.close();
}
} catch (Exception e) {
MainFrame.bslog(e);
}
}
Aggregations