Open GoogleCodeExporter opened 9 years ago
attachment: new output with this settings:
chartData.setNumberOfXAxisTicks(10);//is ok/recognized
chartData.setNumberOfYAxisTicks(10);//is irrilevant!!!
chartData.setXaxisMaxValue(100.0);//what is?
Now I see "6date label": why not 10? All is 1980?! And I don't see any point.
help, thanks
Original comment by mario.de...@gmail.com
on 19 Jul 2011 at 3:07
Attachments:
SOLVED
Sorry, but this code (from tutorial) doesn't work (because I have already
millisecond for date, from date.getTime() and it is unnecessary):
//p1.setX(startTime + (p1.getX().doubleValue() * 1000 * 60));//MUST BE
COMMENTED!!
So, for use jsflot-0.7 with JBoss 5.1+gate 3.1+richfaces 3.3.3+ jsf1.2 (portlet
environment):
-change src to use PortletSession and PortletRequest (instead
HttpServletSession and HttpServletRequest):
src\main\java\org\jsflot\components\ResourcesRenderer.java and
FlotChartRenderer.java
-if you want to use richfaces page scoped bean (a4j:keepAlive) change src
(src\main\java\org\jsflot\xydata) to implements java.io.Serializable
-in the xhtml:
<script language="javascript" type="text/javascript" src="../js/excanvas.js"/> <!-- for IE7 and IE8: you can find it under META-INF -->
<jsflot:resources />
<!-- FORM ID MUST BE PRESENT!!!! -->
<a4j:form id="graphFormId">
<jsflot:flotChart
id="valueTimeChart"
value="#{AwpStoricoContatore.chartSeries}"
showLines="#{AwpStoricoContatore.chartData.showLines}"
fillLines="#{AwpStoricoContatore.chartData.fillLines}"
showDataPoints="#{AwpStoricoContatore.chartData.showDataPoints}"
legendColumns="#{AwpStoricoContatore.chartData.legendColumns}"
legendOpacity="#{AwpStoricoContatore.chartData.legendOpacity}"
legendPosition="#{AwpStoricoContatore.chartData.legendPosition}"
legendColor="#{AwpStoricoContatore.chartData.legendColor}"
height="#{AwpStoricoContatore.chartData.height}"
width="#{AwpStoricoContatore.chartData.width}"
showTooltip="#{AwpStoricoContatore.chartData.showTooltip}"
tooltipPosition="#{AwpStoricoContatore.chartData.tooltipPosition}"
tooltipFollowMouse="#{AwpStoricoContatore.chartData.tooltipFollowMouse}"
mode="#{AwpStoricoContatore.chartData.mode}"
timeFormat="#{AwpStoricoContatore.chartData.timeFormat}"
title="#{AwpStoricoContatore.chartData.title}"
subtitle="#{AwpStoricoContatore.chartData.subtitle}"
chartType="#{AwpStoricoContatore.chartData.chartType}"
showXaxisLabels="#{AwpStoricoContatore.chartData.showXaxisLabels}"
xaxisTitle="#{AwpStoricoContatore.chartData.xaxisTitle}"
xaxisTitleRotation="#{AwpStoricoContatore.chartData.xaxisTitleRotation}"
xaxisLabelRotation="#{AwpStoricoContatore.chartData.xaxisLabelRotation}"
showYaxisLabels="#{AwpStoricoContatore.chartData.showYaxisLabels}"
yaxisTitle="#{AwpStoricoContatore.chartData.yaxisTitle}"
yaxisTitleRotation="#{AwpStoricoContatore.chartData.yaxisTitleRotation}"
yaxisLabelRotation="#{AwpStoricoContatore.chartData.yaxisLabelRotation}"
numberOfXAxisTicks="#{AwpStoricoContatore.chartData.numberOfXAxisTicks}"
xaxisMinValue="#{AwpStoricoContatore.chartData.xaxisMinValue}"
xaxisMaxValue="#{AwpStoricoContatore.chartData.xaxisMaxValue}"
numberOfYAxisTicks="#{AwpStoricoContatore.chartData.numberOfYAxisTicks}"
yaxisMinValue="#{AwpStoricoContatore.chartData.yaxisMinValue}"
markers="#{AwpStoricoContatore.chartData.markers}"
markerPosition="#{AwpStoricoContatore.chartData.markerPosition}"
yaxisMaxValue="#{AwpStoricoContatore.chartData.yaxisMaxValue}"
crosshair="#{AwpStoricoContatore.chartData.crosshair}">
</jsflot:flotChart>
</a4j:form>
-in the jsf bean FOR A GRAPH WITH Y=EURO AND X=DATE (page scoped with
a4j:keepAlive but session scoped is ok):
//start graph
private XYDataList series1DataList = new XYDataList();
private int minX = 0;
private int maxX = 500;
private FlotChartRendererData chartData;
public FlotChartRendererData getChartData() {
return chartData;
}
public void setChartData(FlotChartRendererData chartData) {
this.chartData = chartData;
}
public XYDataSetCollection getChartSeries() {
//dati grafo
XYDataSetCollection collection = new XYDataSetCollection();
XYDataList currentSeries1DataList = new XYDataList();
int size = series1DataList.size();
logger.debug("quanti elementi sulle X ? "+size);
maxX = size-1;
for (int i = minX; i <= maxX; i++) {
long startTime = 1196463600000l;
if (chartData.getMode().equalsIgnoreCase("Time")) {
XYDataPoint p1 = new XYDataPoint(series1DataList.get(i).getX(), series1DataList.get(i).getY(), series1DataList.get(i).getPointLabel());
// p1.setX(startTime + (p1.getX().doubleValue() * 1000 * 60));
currentSeries1DataList.addDataPoint(p1);
} else {
currentSeries1DataList.addDataPoint(series1DataList.get(i));
}
}
//Copy over the meta data for each series to the current viewed-series
currentSeries1DataList.setLabel(series1DataList.getLabel());
currentSeries1DataList.setFillLines(series1DataList.isFillLines());
currentSeries1DataList.setMarkerPosition(series1DataList.getMarkerPosition());
currentSeries1DataList.setMarkers(series1DataList.isMarkers());
currentSeries1DataList.setShowDataPoints(series1DataList.isShowDataPoints());
currentSeries1DataList.setShowLines(series1DataList.isShowLines());
collection.addDataList(currentSeries1DataList);
return collection;
}
//end graph
//***
//*** costruttore
public AwpStoricoContatore() {
_init();
}
private void _init() {
logger.info(">>_init");
//init graph
chartData = new FlotChartRendererData();
chartData.setTitle("Grafico Contatori");
//if"time": JSFlot expects the data points for the X-axis to contain a number representing the number of millisconds since January 1st 1970. Based on the data values shown in the chart, JSFlot will attempt to format the date with a suitable time format. This can be overridden via the timeFormat Attribute.
chartData.setMode("Time");//default is "series"
// chartData.setSubtitle("sottotitolo");
chartData.setXaxisTitle("Data");
chartData.setYaxisTitle("Contatori");
chartData.setShowXaxisLabels(true);
chartData.setShowYaxisLabels(true);
chartData.setShowDataPoints(true);
chartData.setTimeFormat("%d/%m/%y");
chartData.setXaxisLabelRotation(90.0);
chartData.setNumberOfXAxisTicks(20);//numero di label sulle X
chartData.setNumberOfYAxisTicks(20);//numero di label sulle Y
// chartData.setXaxisMaxValue(100.0);//definisce il range di valori visibili:
"tutti i punti che sulla X valgono massimo ..."
// chartData.setYaxisMinValue(5.0);
// chartData.setYaxisMaxValue(10.0);
chartData.setHeight("500");
chartData.setWidth("800");
chartData.setMarkers(false);//valore del punto direttamente sul punto (no se hai una miriade di punti)
chartData.setShowTooltip(true);//valore del punto come tooltip
chartData.setTooltipFollowMouse(true);
series1DataList.setLabel("Andamento Contatori");//nome nella leggenda
series1DataList.setShowDataPoints(true);//il cerchietto che indica ogni punto
series1DataList.setShowLines(true);//linee che collegano i vari punti
//setting values
int i = 0;
for (ContatoriAWPBean bean : listaContatoriAwp) {
int y = bean.getCnttotin();
String dataStr = bean.getDataLettura();
if(dataStr!=null && !dataStr.equals("")){
//millisecond for date
long x = DateUtil.getDate(dataStr, DateUtil.DATE_FORMAT_D).getTime();
series1DataList.addDataPoint(new XYDataPoint(x, y, "Point: " + i));
i++;
}
}
}
logger.info("<<_init");
}
Original comment by mario.de...@gmail.com
on 19 Jul 2011 at 3:54
hello can you help me
how cant y display line from graphe on clik and see it afeter with simple
click ?? thank you ?
Original comment by abb.wa...@gmail.com
on 2 Mar 2013 at 11:35
I have the same problem.
But I tracked it down to a "bug" in the flotr.js.jsf file:
Instead of:
else if(axis.tickUnit=="year"){
d.setUTCFullYear(d.getUTCFullYear()+axis.tickSize);
}
there should be something like:
else if(axis.tickUnit=="year"){
if (axis.tickSize < 1) {
d.setUTCDate(0);
d.setUTCMonth(d.getUTCMonth() + 1);
d.setTime(v + tu.year * axis.tickSize);
d.setUTCHours(0);
}
else
d.setUTCFullYear(d.getUTCFullYear()+axis.tickSize);
}
This is only a draft, because the dates on the x-axis are not the first day of
the month.
Original comment by thomas.k...@googlemail.com
on 15 Oct 2013 at 11:55
Original issue reported on code.google.com by
mario.de...@gmail.com
on 19 Jul 2011 at 2:03Attachments: