IDEMPIERE-1265 Add Adaxa Sales Management. Improve the sizing of dashboard chart gadget.
This commit is contained in:
parent
8a31f38f1a
commit
bb1fbcf7e8
|
@ -62,6 +62,7 @@ import org.zkoss.zk.ui.Component;
|
|||
import org.zkoss.zk.ui.Desktop;
|
||||
import org.zkoss.zk.ui.Executions;
|
||||
import org.zkoss.zk.ui.Page;
|
||||
import org.zkoss.zk.ui.event.AfterSizeEvent;
|
||||
import org.zkoss.zk.ui.event.DropEvent;
|
||||
import org.zkoss.zk.ui.event.Event;
|
||||
import org.zkoss.zk.ui.event.EventListener;
|
||||
|
@ -371,18 +372,32 @@ public class DashboardController implements EventListener<Event> {
|
|||
}
|
||||
|
||||
//chart
|
||||
int AD_Chart_ID = dc.getAD_Chart_ID();
|
||||
final int AD_Chart_ID = dc.getAD_Chart_ID();
|
||||
if (AD_Chart_ID > 0) {
|
||||
Panel chartPanel = new Panel();
|
||||
MChart chartModel = new MChart(Env.getCtx(), AD_Chart_ID, null);
|
||||
ChartRenderer renderer = new ChartRenderer(chartModel);
|
||||
renderer.render(chartPanel, 300);
|
||||
final Div chartPanel = new Div();
|
||||
chartPanel.setSclass("chart-gadget");
|
||||
final MChart chartModel = new MChart(Env.getCtx(), AD_Chart_ID, null);
|
||||
content.appendChild(chartPanel);
|
||||
panelEmpty = false;
|
||||
panelEmpty = false;
|
||||
chartPanel.addEventListener(Events.ON_AFTER_SIZE, new EventListener<AfterSizeEvent>() {
|
||||
@Override
|
||||
public void onEvent(AfterSizeEvent event) throws Exception {
|
||||
ChartRenderer renderer = new ChartRenderer(chartModel);
|
||||
int width = event.getWidth()*90/100;
|
||||
int height = event.getHeight();
|
||||
//set normal height
|
||||
if (height == 0) {
|
||||
height = width * 85 / 100;
|
||||
chartPanel.setHeight(height+"px");
|
||||
}
|
||||
chartPanel.getChildren().clear();
|
||||
renderer.render(chartPanel, width, height);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (panelEmpty)
|
||||
panel.detach();
|
||||
panel.detach();
|
||||
}
|
||||
|
||||
if (dps.length == 0)
|
||||
|
|
|
@ -22,6 +22,7 @@ import org.compiere.util.Env;
|
|||
import org.zkoss.zk.ui.event.Event;
|
||||
import org.zkoss.zk.ui.event.Events;
|
||||
import org.zkoss.zul.Panel;
|
||||
import org.zkoss.zul.Panelchildren;
|
||||
|
||||
/**
|
||||
* This class is based on org.compiere.grid.ed.WImageEditor and WGraph written by Low Heng Sin.
|
||||
|
@ -50,7 +51,15 @@ public class WChartEditor extends WEditor
|
|||
|
||||
private void createChart() {
|
||||
ChartRenderer renderer = new ChartRenderer(chartModel);
|
||||
renderer.render(getComponent(), 400);
|
||||
Panel panel = getComponent();
|
||||
if (panel.getPanelchildren() != null) {
|
||||
panel.getPanelchildren().getChildren().clear();
|
||||
} else {
|
||||
Panelchildren pc = new Panelchildren();
|
||||
panel.appendChild(pc);
|
||||
pc.setSclass("chart-field");
|
||||
}
|
||||
renderer.render(panel.getPanelchildren(), 400, chartModel.getWinHeight());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -20,14 +20,13 @@ import org.jfree.data.time.TimeSeries;
|
|||
import org.jfree.data.time.TimeSeriesCollection;
|
||||
import org.jfree.data.time.TimeSeriesDataItem;
|
||||
import org.zkoss.image.AImage;
|
||||
import org.zkoss.zk.ui.Component;
|
||||
import org.zkoss.zk.ui.event.Event;
|
||||
import org.zkoss.zk.ui.event.EventListener;
|
||||
import org.zkoss.zk.ui.event.Events;
|
||||
import org.zkoss.zk.ui.event.MouseEvent;
|
||||
import org.zkoss.zul.Area;
|
||||
import org.zkoss.zul.Imagemap;
|
||||
import org.zkoss.zul.Panel;
|
||||
import org.zkoss.zul.Panelchildren;
|
||||
|
||||
/**
|
||||
* @author Paul Bowden, Adaxa Pty Ltd
|
||||
|
@ -52,11 +51,10 @@ public class ChartRenderer {
|
|||
* @param panel
|
||||
* @param width
|
||||
*/
|
||||
public void render(Panel panel, int width) {
|
||||
public void render(Component parent, int width, int height) {
|
||||
JFreeChart chart = chartModel.createChart();
|
||||
|
||||
ChartRenderingInfo info = new ChartRenderingInfo();
|
||||
int height = chartModel.getWinHeight();
|
||||
BufferedImage bi = chart.createBufferedImage(width, height,
|
||||
BufferedImage.TRANSLUCENT, info);
|
||||
try {
|
||||
|
@ -66,15 +64,7 @@ public class ChartRenderer {
|
|||
Imagemap myImage = new Imagemap();
|
||||
|
||||
myImage.setContent(image);
|
||||
if (panel.getPanelchildren() != null) {
|
||||
panel.getPanelchildren().getChildren().clear();
|
||||
panel.getPanelchildren().appendChild(myImage);
|
||||
} else {
|
||||
Panelchildren pc = new Panelchildren();
|
||||
panel.appendChild(pc);
|
||||
pc.appendChild(myImage);
|
||||
pc.setSclass("chart-field");
|
||||
}
|
||||
parent.appendChild(myImage);
|
||||
|
||||
int count = 0;
|
||||
for (Iterator<?> it = info.getEntityCollection().getEntities()
|
||||
|
|
|
@ -1931,7 +1931,11 @@ table.z-vbox > tbody > tr > td > table {
|
|||
background-color: #ddd;
|
||||
}
|
||||
|
||||
<%-- chart --%>
|
||||
.chart-field {
|
||||
padding: 10px;
|
||||
border: 1px solid lightgray !important;
|
||||
}
|
||||
.dashboard-widget.dashboard-widget-max .chart-gadget {
|
||||
height: 100% !important;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue