Skip to content

Commit

Permalink
small improvements because of chartjs integration (instead of jqplot)
Browse files Browse the repository at this point in the history
  • Loading branch information
SteffenHankiewicz committed Nov 21, 2023
1 parent a25f1d3 commit a767cf9
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 87 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,86 +12,40 @@

<composite:implementation>

<script type="text/javascript">
function ext() {

// this.cfg.title='mein neues Diagramm';

this.cfg.grid = {
background: 'transparent',
drawGridlines: true,
gridLineWidth: 0.25,
gridLineColor: '#ccc',
drawBorder: true,
borderWidth: 0.25,
shadow: false,
};

this.cfg.axes.yaxis.label='#{msgs.prozesse}';
this.cfg.axes.xaxis.label='#{msgs.monate}';

this.cfg.seriesColors=['#368EE0', '#00749F', '#73C774', '#C7754C', '#17BDB8'];

this.cfg.seriesDefaults = {
shadow: false,
pointLabels: { show: true }
};

this.cfg.axesDefaults = {
labelRenderer: $.jqplot.CanvasAxisLabelRenderer,

};

this.cfg.axes = {
xaxis:{
renderer:$.jqplot.CategoryAxisRenderer,
tickRenderer: $.jqplot.CanvasAxisTickRenderer ,
tickOptions: {
angle: -50,
fontSize: '8pt',
fontFamily: 'Goobi',
textColor: '#000000',
}
},
yaxis:{
tickRenderer: $.jqplot.CanvasAxisTickRenderer ,
tickOptions: {
fontSize: '8pt',
fontFamily: 'Goobi',
textColor: '#000000',
formatString: "%d"
<h:outputScript>
function chartExtender() {
var options = $.extend(true, {}, this.cfg.config);
options = {
options: {
plugins: {
title: {
display: false,
text: "Processes per month"
},
min:0,
legend: {
display: false
}
}
};

}
</script>
<ui:fragment rendered="#{DashboardForm.plugin.processHelper.showStatistics and !DashboardForm.plugin.processHelper.isProcessPerMonthEmpty()}">
<style>
.jqplot-title {
font-size: 28px;
}
.jqplot-point-label {
font-size: 12px;
}

</style>

<div class="mb-3">
<intranda:box
boxType="primary"
boxPadding="true"
icon="fa-list"
title="#{msgs.dashboard_processesPerMonth}">
<div class="card">
<p:lineChart
model="#{DashboardForm.plugin.processHelper.processesPerMonth}"
class="monthly-processes"/>
</div>
</intranda:box>
</div>

</ui:fragment>
};
$.extend(true, this.cfg.config, options);
};
</h:outputScript>
<ui:fragment rendered="#{DashboardForm.plugin.processHelper.showStatistics and !DashboardForm.plugin.processHelper.isProcessPerMonthEmpty()}">
<div class="mb-3">
<intranda:box
boxType="primary"
boxPadding="true"
icon="fa-list"
title="#{msgs.dashboard_processesPerMonth}">
<div class="card">
<p:lineChart
model="#{DashboardForm.plugin.processHelper.processesPerMonth}"
style="height:250px"/>
</div>
</intranda:box>
</div>

</ui:fragment>
</composite:implementation>
</ui:composition>
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ public class DashboardHelperProcesses {
private XMLConfiguration config;
private LineChartModel processesPerMonth = null;



public DashboardHelperProcesses(XMLConfiguration xmlConfiguration) {
config = xmlConfiguration;
}
Expand All @@ -38,7 +36,7 @@ public LineChartModel getProcessesPerMonth() {
List<Object[]> rawvalues = ControllingManager.getResultsAsObjectList(sql);
for (Object[] objArr : rawvalues) {
String projectId = (String) objArr[0];
if (strProjecIds.length()> 1) {
if (strProjecIds.length() > 1) {
strProjecIds += ",";
}
strProjecIds += projectId;
Expand All @@ -47,15 +45,13 @@ public LineChartModel getProcessesPerMonth() {

strProjecIds += ")";


List<Object> values = new ArrayList<>();
List<String> labels = new ArrayList<>();



List<?> list = ProcessManager.runSQL(
"Select year(erstellungsdatum) as year, month(erstellungsdatum) as month, count(*) FROM prozesse WHERE IstTemplate=false AND ProjekteID in " +
strProjecIds + " GROUP BY year, month ORDER BY year desc, month desc LIMIT 24;");
"Select year(erstellungsdatum) as year, month(erstellungsdatum) as month, count(*) FROM prozesse WHERE IstTemplate=false AND ProjekteID in "
+
strProjecIds + " GROUP BY year, month ORDER BY year desc, month desc LIMIT 24;");
Collections.reverse(list);
for (Object obj : list) {
Object[] o = (Object[]) obj;
Expand All @@ -78,7 +74,6 @@ public LineChartModel getProcessesPerMonth() {

data.setLabels(labels);


//Options
LineChartOptions options = new LineChartOptions();
options.setMaintainAspectRatio(false);
Expand All @@ -97,6 +92,7 @@ public LineChartModel getProcessesPerMonth() {
options.setLegend(legend);
processesPerMonth.setOptions(options);
processesPerMonth.setData(data);
processesPerMonth.setExtender("chartExtender");
}
return this.processesPerMonth;
}
Expand Down

0 comments on commit a767cf9

Please sign in to comment.