Skip to content

Commit

Permalink
Merge pull request 'generate new chart' (#17) from update_primefaces …
Browse files Browse the repository at this point in the history
  • Loading branch information
janvonde committed Nov 4, 2023
2 parents e845f94 + 9678b41 commit b152ee4
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 47 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
.jqplot-point-label {
font-size: 12px;
}

</style>

<div class="mb-3">
Expand All @@ -83,10 +84,11 @@
boxPadding="true"
icon="fa-list"
title="#{msgs.dashboard_processesPerMonth}">

<p:chart type="line"
model="#{DashboardForm.plugin.processHelper.processesPerMonth}"
style="height:300px;"/>
<div class="card">
<p:lineChart
model="#{DashboardForm.plugin.processHelper.processesPerMonth}"
style="width: 100%; height:300px;"/>
</div>
</intranda:box>
</div>

Expand Down
2 changes: 1 addition & 1 deletion plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<version>23.08</version>
<packaging>pom</packaging>
<properties>
<goobi.version>23.08</goobi.version>
<goobi.version>23.09-SNAPSHOT</goobi.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<modules>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,37 +1,17 @@
package de.intranda.digiverso.model.helper;

/**
* This file is part of a plugin for the Goobi Application - a Workflow tool for the support of mass digitization.
*
* Visit the websites for more information.
* - https://goobi.io
* - https://www.intranda.com
* - https://github.com/intranda/goobi
*
* This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free
* Software Foundation; either version 2 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59
* Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Linking this library statically or dynamically with other modules is making a combined work based on this library. Thus, the terms and conditions
* of the GNU General Public License cover the whole combination. As a special exception, the copyright holders of this library give you permission to
* link this library with independent modules to produce an executable, regardless of the license terms of these independent modules, and to copy and
* distribute the resulting executable under terms of your choice, provided that you also meet, for each linked independent module, the terms and
* conditions of the license of that module. An independent module is a module which is not derived from or based on this library. If you modify this
* library, you may extend this exception to your version of the library, but you are not obliged to do so. If you do not wish to do so, delete this
* exception statement from your version.
*/
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

import org.apache.commons.configuration.XMLConfiguration;
import org.goobi.beans.User;
import org.primefaces.model.chart.ChartSeries;
import org.primefaces.model.chart.LineChartModel;
import org.primefaces.model.charts.ChartData;
import org.primefaces.model.charts.line.LineChartDataSet;
import org.primefaces.model.charts.line.LineChartModel;
import org.primefaces.model.charts.line.LineChartOptions;
import org.primefaces.model.charts.optionconfig.legend.Legend;
import org.primefaces.model.charts.optionconfig.title.Title;

import de.sub.goobi.helper.Helper;
import de.sub.goobi.persistence.managers.ControllingManager;
Expand All @@ -49,7 +29,7 @@ public DashboardHelperProcesses(XMLConfiguration xmlConfiguration) {

public LineChartModel getProcessesPerMonth() {
if (this.processesPerMonth == null) {

String strProjecIds = "(";
User user = Helper.getCurrentUser();
if (user != null) {
Expand All @@ -59,32 +39,64 @@ public LineChartModel getProcessesPerMonth() {
for (Object[] objArr : rawvalues) {
String projectId = (String) objArr[0];
if (strProjecIds.length()> 1) {
strProjecIds += ",";
strProjecIds += ",";
}
strProjecIds += projectId;
}
}

strProjecIds += ")";

LineChartModel model = new LineChartModel();
model.setExtender("ext");
ChartSeries series = new ChartSeries();
series.setLabel("Months");

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 " +
"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;
String label = o[0] + "/" + o[1];
Integer number = Integer.valueOf((String) o[2]);
series.set(label, number);
values.add(number);
labels.add(label);
}
processesPerMonth = new LineChartModel();
ChartData data = new ChartData();

LineChartDataSet dataSet = new LineChartDataSet();

model.addSeries(series);
this.processesPerMonth = model;
dataSet.setData(values);
dataSet.setFill(false);
dataSet.setLabel("");
dataSet.setBorderColor("rgb(54, 142, 224)");
dataSet.setTension(0.1);
data.addChartDataSet(dataSet);

data.setLabels(labels);


//Options
LineChartOptions options = new LineChartOptions();
options.setMaintainAspectRatio(false);
Title title = new Title();
title.setDisplay(false);
title.setText("Line Chart");
options.setTitle(title);

Title subtitle = new Title();
subtitle.setDisplay(false);
subtitle.setText("Line Chart Subtitle");
options.setSubtitle(subtitle);

Legend legend = new Legend();
legend.setDisplay(false);
options.setLegend(legend);
processesPerMonth.setOptions(options);
processesPerMonth.setData(data);
}
return this.processesPerMonth;
}
Expand All @@ -101,10 +113,10 @@ public boolean isShowProcessTemplates() {
}

public boolean isProcessPerMonthEmpty() {

List<?> list = ProcessManager.runSQL(
"Select year(erstellungsdatum) as year, month(erstellungsdatum) as month, count(*) FROM prozesse WHERE IstTemplate=false GROUP BY year, month ORDER BY year desc, month desc LIMIT 24;");

return list.isEmpty();
}

Expand Down

0 comments on commit b152ee4

Please sign in to comment.