ro.nextreports.engine.chart.NextChart Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of nextreports-engine Show documentation
Show all versions of nextreports-engine Show documentation
NextReports Engine is a lightweight Java platform development library which
can be used to run NextReports inside your applications.
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package ro.nextreports.engine.chart;
import java.io.StringWriter;
import java.util.ArrayList;
import java.util.List;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.fasterxml.jackson.databind.ObjectMapper;
/*
* @author Mihai Dinca-Panaitescu
*/
public class NextChart {
public static enum Type { bar, stackedbar, hbar, hstackedbar, line, area, pie, barcombo, stackedbarcombo, bubble };
public static enum Style { normal, glass, cylinder, dome, parallelepiped, soliddot, hollowdot, anchordot, bowdot, stardot };
public static enum Orientation { horizontal, vertical, diagonal, halfdiagonal };
public static enum Alignment { left, center, right };
private List> data = new ArrayList>();
private List> lineData = new ArrayList>();
private Type type;
private Style style;
private String background;
private List labels = new ArrayList();
private List categories = new ArrayList();
private Orientation labelOrientation;
private List color = new ArrayList();
private List lineColor = new ArrayList();
private List legend = new ArrayList();
private List lineLegend = new ArrayList();
private Number alpha;
private String colorXaxis;
private String colorYaxis;
private boolean showGridX;
private boolean showGridY;
private boolean showLabels;
private String colorGridX;
private String colorGridY;
private String message;
private int tickCount;
private boolean showTicks = true;
private boolean startingFromZero = false;
private NextChartTitle title;
private NextChartAxis xData;
private NextChartAxis yData;
private NextChartLegend xLegend;
private NextChartLegend yLegend;
private NextNumberFormat tooltipPattern;
private boolean dualYaxis;
private NextChartLegend y2Legend;
private int y2Count;
// function doClick(value){ console.log('Call from function : ' + value);}
private String onClick;
public NextChart() {
}
public Type getType() {
return type;
}
public void setType(Type type) {
this.type = type;
}
public Style getStyle() {
return style;
}
public void setStyle(Style style) {
this.style = style;
}
public List> getData() {
return data;
}
public void setData(List> data) {
this.data = data;
}
public String getBackground() {
return background;
}
public void setBackground(String background) {
this.background = background;
}
public List getLabels() {
return labels;
}
public void setLabels(List labels) {
this.labels = labels;
}
public List getCategories() {
return categories;
}
public void setCategories(List categories) {
this.categories = categories;
}
public Orientation getLabelOrientation() {
return labelOrientation;
}
public void setLabelOrientation(Orientation labelOrientation) {
this.labelOrientation = labelOrientation;
}
public List getColor() {
return color;
}
public void setColor(List color) {
this.color = color;
}
public List getLegend() {
return legend;
}
public void setLegend(List legend) {
this.legend = legend;
}
public Number getAlpha() {
return alpha;
}
public void setAlpha(Number alpha) {
this.alpha = alpha;
}
public String getColorXaxis() {
return colorXaxis;
}
public void setColorXaxis(String colorXaxis) {
this.colorXaxis = colorXaxis;
}
public String getColorYaxis() {
return colorYaxis;
}
public void setColorYaxis(String colorYaxis) {
this.colorYaxis = colorYaxis;
}
public boolean isShowGridX() {
return showGridX;
}
public void setShowGridX(boolean showGridX) {
this.showGridX = showGridX;
}
public boolean isShowGridY() {
return showGridY;
}
public void setShowGridY(boolean showGridY) {
this.showGridY = showGridY;
}
public boolean isShowLabels() {
return showLabels;
}
public void setShowLabels(boolean showLabels) {
this.showLabels = showLabels;
}
public String getColorGridX() {
return colorGridX;
}
public void setColorGridX(String colorGridX) {
this.colorGridX = colorGridX;
}
public String getColorGridY() {
return colorGridY;
}
public void setColorGridY(String colorGridY) {
this.colorGridY = colorGridY;
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
public int getTickCount() {
return tickCount;
}
public void setTickCount(int tickCount) {
this.tickCount = tickCount;
}
public NextChartTitle getTitle() {
return title;
}
public void setTitle(NextChartTitle title) {
this.title = title;
}
public NextChartAxis getxData() {
return xData;
}
public void setxData(NextChartAxis xData) {
this.xData = xData;
}
public NextChartAxis getyData() {
return yData;
}
public void setyData(NextChartAxis yData) {
this.yData = yData;
}
public NextChartLegend getxLegend() {
return xLegend;
}
public void setxLegend(NextChartLegend xLegend) {
this.xLegend = xLegend;
}
public NextChartLegend getyLegend() {
return yLegend;
}
public void setyLegend(NextChartLegend yLegend) {
this.yLegend = yLegend;
}
public boolean isDualYaxis() {
return dualYaxis;
}
public void setDualYaxis(boolean dualYaxis) {
this.dualYaxis = dualYaxis;
}
public NextChartLegend getY2Legend() {
return y2Legend;
}
public void setY2Legend(NextChartLegend y2Legend) {
this.y2Legend = y2Legend;
}
public int getY2Count() {
return y2Count;
}
public void setY2Count(int y2Count) {
this.y2Count = y2Count;
}
public boolean isShowTicks() {
return showTicks;
}
public void setShowTicks(boolean showTicks) {
this.showTicks = showTicks;
}
public boolean isStartingFromZero() {
return startingFromZero;
}
public void setStartingFromZero(boolean startingFromZero) {
this.startingFromZero = startingFromZero;
}
public NextNumberFormat getTooltipPattern() {
return tooltipPattern;
}
public void setTooltipPattern(NextNumberFormat tooltipPattern) {
this.tooltipPattern = tooltipPattern;
}
public List> getLineData() {
return lineData;
}
public void setLineData(List> lineData) {
this.lineData = lineData;
}
public List getLineColor() {
return lineColor;
}
public void setLineColor(List lineColor) {
this.lineColor = lineColor;
}
public List getLineLegend() {
return lineLegend;
}
public void setLineLegend(List lineLegend) {
this.lineLegend = lineLegend;
}
public String getOnClick() {
return onClick;
}
public void setOnClick(String onClick) {
this.onClick = onClick;
}
public String toJson() {
ObjectMapper mapper = new ObjectMapper();
mapper.setSerializationInclusion(Include.NON_NULL);
mapper.setSerializationInclusion(Include.NON_EMPTY);
StringWriter writer = new StringWriter();
try {
mapper.writeValue(writer, this);
return writer.toString();
} catch (Exception ex) {
ex.printStackTrace();
return "Error : " + ex.getMessage();
}
}
}