|
bars showed after refresh page |
Posted by Alberto on Jul-19-2012 22:28 |
|
Hi all
I have an application that show 6 charts, my problem is when the page open with the charts don't show the bars but when i refresh the page (F5) the bars appears.
Please help me |
Re: bars showed after refresh page |
Posted by Peter Kwan on Jul-21-2012 00:03 |
|
Hi Alberto,
Do you mean that when the page open, all the charts are displayed normally but with no bars (that is, you can only see an empty plot area with no bars), and when you press F5, all the charts displayed normally and this time have bars?
The the charts displayed normally but does not contain bars, it may be because your code does not provide any data. Have you checked that your code provide data to ChartDirector when the page is first opened? If you want to further diagnose the problem, would you mind to inform me of the charting part of your code?
If even the charts do not display (eg, you see the "red X" broken image symbol in the browser), then please try the sample code "Background and Wallpaper" that comes with ChartDirector. This sample code displays multiple bars chart in the same web page. Does the sample code works? If the sample code works, but your real code does not work, the error may be specific to your code. In this case, would you mind to inform me of the charting part of your code?
Regards
Peter Kwan |
Re: bars showed after refresh page |
Posted by Robert on Jul-21-2012 00:23 |
|
Hi Peter
Yes all the charts are displayed normally but with no bars and the charts displayed normally with bars and sometimes show a bar with 1 value
Yes Peter i have checked that the code provide data to ChartDirector when the page is first opened
And when i check the code in the page with show source code option i see a line like this <area shape="rect" coords="371,70,404,127" title='JUL - 17 - Servicios VALIDADO'>. The 17 number must be displayed but the page show no bars
Regards
|
Re: bars showed after refresh page |
Posted by Alberto on Jul-21-2012 01:14 |
|
Hi Peter
I found something strange. If i point the cursor on the bottom of the bar show a hint with the value that the bar must display.
|
Re: bars showed after refresh page |
Posted by Peter Kwan on Jul-21-2012 03:12 |
|
Hi Alberto,
I suspect the chart is drawn with no data. That's why all the bars are zeros. From your description, the tooltips work normally. So I suspect the chart does not match the tooltips. The HTML in your web page may reflect the image map for your real bar chart, but displays another bar chart with zero bars.
There are many reasons why the above can happen. For example, the browser may be displaying the chart image from browser cache. So the browser is not really loading the latest chart image from the server, but is using an old chart in the browser cache. But the HTML is from the server. So the HTML image map does not match the image. When you press F5 to refresh the web page, the browser loads the real image from the server, so the image now shows the real bar chart and matches the image map.
Another possibility is that your code actually creates two charts for some unknown reasons. One of the charts contain zero bars, and is the one used for the initial display.
The above are only some of the possible reasons. There can be other reasons. That's why I may need to see your actual code to see how to start trouble-shooting the problem.
One common method to trouble-shoot the problem is to include the timestamp and the data in the chart. Currently, I do not know which programming language or framework you are using, so I will use PHP in the following example.
(1) Please include an accurate timestamp in both your web page and the chart image. For example, in the chart image, you may add it in the chart title:
#replace your chart title with the followings
$timeStamp = microtime();
$c->addTitle("TimeStamp = $timeStamp");
You should put the same microtime() in your web page. By checking the timeStamp in the chart and in the HTML output, we can know if the image map and the chart image is generated by the same PHP script instance, or is the chart image from an earlier instance (and remains in the browser cache).
(2) Include some data value in the chart display. For example, suppose you have the following code:
$layer->addDataSet($myData, -1, "AUTORIZADO");
You can change the above to:
$layer->addDataSet($myData, -1, "AUTORIZADO=[".$myData[0]."]");
You can do the above for all your other data series. In this way, you should see the first data values in the legend box, and you can check if the data values are really all zeros.
Regards
Peter Kwan |
Re: bars showed after refresh page |
Posted by Alberto on Jul-21-2012 04:30 |
|
I'm sorry Peter i forgot to mention i'm using java to get the values and javascript to show the chart. Could you give me the timestamp example to add it to my javascript code
Thanks |
Re: bars showed after refresh page |
Posted by Alberto on Jul-21-2012 04:52 |
|
Hi Peter
I send you my jsp code. I hope you can help me.
Regards
|
Re: bars showed after refresh page |
Posted by Peter Kwan on Jul-23-2012 23:01 |
|
Hi Alberto,
In your JSP, the chart is generated using Java code. Apparently, the data are added to the chart through "voFRM". It is not clear to me what is voFRM, and I do not have the source code for voFRM to trace into the code. Anyway, I found in your code, there is a line:
voGraficaXY=new XYChart(950,400);
To add a timestamp to the top-left corner of the chart, you may use:
long timeStamp = new Date().getTime();
voGraficaXY.addText(0, 0, "t=" + timeStamp);
Remember to put the same timestamp in the HTML code and in the image map, so that we can compare the timestamp in the HTML and image map to that in the chart to see if they match. In your original code, I see the lines:
<img src='<%=response.encodeURL("frmGrafica.jsp?"+vsImgChart1)%>'usemap="#map<%=viAux2%>" border="0">
<map name="map<%=viAux2%>"><%=voFRM.getGrafica().getHTMLImageMap("", "","title='{xLabel} - {value} - Servicios {dataSetName}'" )%></map>
You may change them to include the timeStamp:
<div><b>t=<%=timeStamp%></b></div>
<img src='<%=response.encodeURL("frmGrafica.jsp?"+vsImgChart1)%>'usemap="#map<%=viAux2%>" border="0">
<map name="map<%=viAux2%>"><%=voFRM.getGrafica().getHTMLImageMap("", "","title='[t=" + timeStamp + "] {xLabel} - {value} - Servicios {dataSetName}'" )%></map>
As I am not sure what is voFRM, I can only guess. I guess that the data are added to the chart using the line:
voFRM.prcGraficaBarras(voValores,voGraficaXY, (String) voEntidad.getKey());
In the above, voValores seems to be the data. I see that in your code, you never display the data in the web page, so we do not know the values in it . (The table in your web page is not displaying voValores.) If the above is really the line that adds the data to the chart, you may include the first data value in the legend key (I assume to be voEntidad.getKey()) to check the data values.
voFRM.prcGraficaBarras(voValores, voGraficaXY, ((String)voEntidad.getKey()) + " " + voValores[0]);
Please kindly let me know what is the result by saving the output of your web page. (From the browser, select "File/Save As" and save the output as a web archive.)
Regards
Peter Kwan |
Re: bars showed after refresh page |
Posted by Alberto on Jul-23-2012 23:13 |
|
Hi Peter, thanks for helping
voFRM is a variable declared in my JSP
FRMOTRRPR005A voFRM = new FRMOTRRPR005A(voIO);
I send my java file to which the variable refers voFRM
Thanks in advance
|
Re: bars showed after refresh page |
Posted by Alberto on Jul-23-2012 23:47 |
|
Hi Peter
I send you an image file with the result of add the 2 timestamp and a rar file with the html file of the result.
I use the 2 timestamp like this
long timeStamp = new Date().getTime();
voGraficaXY.addText(0, 0, "t1=" + timeStamp);
<div><b>t2=<%=timeStamp%></b></div>
Thanks
|
Re: bars showed after refresh page |
Posted by Peter Kwan on Jul-24-2012 02:24 |
|
Hi Alberto,
After seeing your actual HTML output, I find that your web page actually have 16 charts. Furthermore, 8 of the charts use the same session variable name "chart1", and the other 8 uses "chart2".
Since you are using the same session variable name "chart1" for the 8 charts, they will overwrite each others. So when you create the 2nd chart, it will overwrite the first chart, and so on. So at the end, the session variable "chart1" contains the last chart, which is all zeros. So all the 8 images which shows "chart1", will display zero bars. Similarly, all the 8 images which shows "chart2" will display the last chart, which is also all zeros.
To solve the problem, please use a different session variable name for each chart. For example, you may called it "chart0", "chart1", "chart2", ..., just like how you name the image map.
Hope this can help.
Regards
Peter Kwan |
Re: bars showed after refresh page |
Posted by Alberto on Jul-24-2012 21:54 |
|
Thank Peter that resolved my problem, now the graphics are displayed without problems
I use something like this
<img src='<%=response.encodeURL("frmGrafica.jsp?"+ voFRM.getGraficaPorcentaje().makeSession(request,"chart2"+viAux2))%>'usemap="#map<%=viAux2%>" border="0">
where viAux2 is a counter that makes the difference between the names of the graphs
Thanks again |
|