JSF Chart Creator Component Based on JFreeChart
RC1 mostly works
I was able to get the RC1 working. The things I had to do:
- Clean up the old 1.1.0 jar files from the webapps dir.
- Get the new jfreechart-1.1 and jcommons-1.X (I got 5, maybe 1.1 would work
- remove the chart from web.xml.
The example won't work. It says background="gray", but ChartUtils.java has:
if (color.equalsIgnoreCase("grey"))
Maybe changing that to
if ((color.equalsIgnoreCase("grey")) || (color.equalsIgnoreCase("gray")))
would allow both versions to work. (then down farther, darkgray and lightgray could be the same)
- Clean up the old 1.1.0 jar files from the webapps dir.
- Get the new jfreechart-1.1 and jcommons-1.X (I got 5, maybe 1.1 would work
- remove the chart from web.xml.
The example won't work. It says background="gray", but ChartUtils.java has:
if (color.equalsIgnoreCase("grey"))
Maybe changing that to
if ((color.equalsIgnoreCase("grey")) || (color.equalsIgnoreCase("gray")))
would allow both versions to work. (then down farther, darkgray and lightgray could be the same)
Doesn't help - Chart Creator Release candidate still broke
I did what you suggested and although now the legend is somewhat different ( little dots rather than squares ), once I goto the jsf tab which contains the chart and the chart draws. Navigating the application at all stops. Any attempt to do anything, just redraws the chart. It's like every http request is being intercepted by the phase listener and just does it's thing with the chart and that's it.
BTW: Why the dependency on faces pattern being *.jsf? Everybody isn't doing that. Our whole application is based on /faces/*
Since the standard is split... This has to break Chart Creator for half the myFaces developers.... But that said... Adding the mapping *.jsf has no effect.
This is horrible! - Our software releases Monday and I can't release with Chart Creator broken....
John
BTW: Why the dependency on faces pattern being *.jsf? Everybody isn't doing that. Our whole application is based on /faces/*
Since the standard is split... This has to break Chart Creator for half the myFaces developers.... But that said... Adding the mapping *.jsf has no effect.
This is horrible! - Our software releases Monday and I can't release with Chart Creator broken....
John
-
- Posts: 54
- Joined: Sun Aug 28, 2005 8:13 pm
Hi,
I see, the thing is if the /faces/* mapping is already defined, there is no need for *.jsf. Due to the relative path, charts will be displayed.
John, I'm working to reproduce the bug you reported but no luck. I've tried lots of things, navigation, postback and more. Everything worked. Also many people told me that the new version is working good, I guess the new structure collides with your configuration somehow.
Can you send me an example page of yours?
Regards,
Cagatay
I see, the thing is if the /faces/* mapping is already defined, there is no need for *.jsf. Due to the relative path, charts will be displayed.
John, I'm working to reproduce the bug you reported but no luck. I've tried lots of things, navigation, postback and more. Everything worked. Also many people told me that the new version is working good, I guess the new structure collides with your configuration somehow.
Can you send me an example page of yours?
Regards,
Cagatay
Yes, that makes sense. That's why I saw no change in the behavior before & after adding the *.jsf mapping.
I emailed you the complete war as an attachment.
There's alot of surperflous stuff in there, but the actual application is
main.jsp
changePassword.jsp
errorPage.jsp
login.jsp
register.jsp
Main uses tag files
layout/content.tag
layout/header.tag
layout/footer.tag
Then the majority of the tobago code is in the tag files for the tabs:
tabs/charts.tag
tabs/quarantine.tag
tabs/whitelist.tag
charts.tag is where your tag is.
Thanks,
John
I emailed you the complete war as an attachment.
There's alot of surperflous stuff in there, but the actual application is
main.jsp
changePassword.jsp
errorPage.jsp
login.jsp
register.jsp
Main uses tag files
layout/content.tag
layout/header.tag
layout/footer.tag
Then the majority of the tobago code is in the tag files for the tabs:
tabs/charts.tag
tabs/quarantine.tag
tabs/whitelist.tag
charts.tag is where your tag is.
Thanks,
John
In your tests are you inserting your chart tag in the middle of a page with JSF actions and serverside tabbing and everything going on, or are you just putting the charts on their own pages like your examples?cagatay_civici wrote:Hi,
I see, the thing is if the /faces/* mapping is already defined, there is no need for *.jsf. Due to the relative path, charts will be displayed.
John, I'm working to reproduce the bug you reported but no luck. I've tried lots of things, navigation, postback and more. Everything worked. Also many people told me that the new version is working good, I guess the new structure collides with your configuration somehow.
Can you send me an example page of yours?
Regards,
Cagatay
John
-
- Posts: 54
- Joined: Sun Aug 28, 2005 8:13 pm
Yes, I've added JSF actions, navigation cases, regular postbacks and etc. to the pages with charts. I've not observed any problem and could not reproduce the bug you mentioned.
I wonder what is wrong with your case, I could not deploy the example you sent me due to some class version problems of tobago. Maybe the problem is with tobago - chartlistener conflict.
Anyone tried the new version and encountered a problem?
I wonder what is wrong with your case, I could not deploy the example you sent me due to some class version problems of tobago. Maybe the problem is with tobago - chartlistener conflict.
Anyone tried the new version and encountered a problem?
Not sure if this is it, but, the following code; since I'm using tabs within the same main.jsp page, wouldn't this code always return the same page and exhibit the exact behavior I'm seeing?cagatay_civici wrote:Yes, I've added JSF actions, navigation cases, regular postbacks and etc. to the pages with charts. I've not observed any problem and could not reproduce the bug you mentioned.
I wonder what is wrong with your case, I could not deploy the example you sent me due to some class version problems of tobago. Maybe the problem is with tobago - chartlistener conflict.
Anyone tried the new version and encountered a problem?
public void afterPhase(PhaseEvent phaseEvent) {
String rootId = phaseEvent.getFacesContext().getViewRoot().getViewId();
if (rootId.indexOf(CHART_REQUEST) != -1) {
handleChartRequest(phaseEvent);
}
}
Changing Y range?
Is there a way to get at the Plot for the chart, or other way to change the range? (get the dataset change event, or other way?).
I have an XY dataset that goes from 80000 to 175000, and it looks really funny with nothing below 80000.
Thanks
I have an XY dataset that goes from 80000 to 175000, and it looks really funny with nothing below 80000.
Thanks
Feeping Creatures
Before RC2 (or 3?) would it be possible to add a start and end range
for XYarea charts.
In chartlet.java, createChartWithXYDataSet() add a:
XYPlot plot = (XYPlot) chart.getPlot();
NumberAxis yAxis = (NumberAxis)plot.getRangeAxis();
yAxis.setLowerBound(lowerBound);
yAxis.setUpperBound(upperBound);
Similar to the start angle for the pie charts.
Then add the upper and lower bounds to UIChart.java, ChartTag.java, and ChartUtils.java.
Maybe please?
thanks
for XYarea charts.
In chartlet.java, createChartWithXYDataSet() add a:
XYPlot plot = (XYPlot) chart.getPlot();
NumberAxis yAxis = (NumberAxis)plot.getRangeAxis();
yAxis.setLowerBound(lowerBound);
yAxis.setUpperBound(upperBound);
Similar to the start angle for the pie charts.
Then add the upper and lower bounds to UIChart.java, ChartTag.java, and ChartUtils.java.
Maybe please?
thanks
-
- Posts: 54
- Joined: Sun Aug 28, 2005 8:13 pm
Hi,
John, the request for charts and the page it self is identified with the view id. A tab change results in a postback and the request lifecycle starts for the page, chart requests are also fired. The request for the page has the different view id than the charts so this check is needed to identify it. I don't think this is the problem.
Cozytom, consider the range thing done
Regards,
Cagatay
John, the request for charts and the page it self is identified with the view id. A tab change results in a postback and the request lifecycle starts for the page, chart requests are also fired. The request for the page has the different view id than the charts so this check is needed to identify it. I don't think this is the problem.
Cozytom, consider the range thing done

Regards,
Cagatay
At the risk of being argumentative....cagatay_civici wrote:Hi,
John, the request for charts and the page it self is identified with the view id. A tab change results in a postback and the request lifecycle starts for the page, chart requests are also fired. The request for the page has the different view id than the charts so this check is needed to identify it. I don't think this is the problem.
Cozytom, consider the range thing done
Regards,
Cagatay
What you just described, seems to support my theory...
I basically have 3 applications on my page using tabs.
Each "application" is a tag file within it's individual tab
When I'm in the 3rd tab (which has the charting app [tag file]), any punching on another tab just redraws the chart within the 3rd tab.
Your description seems to explain this because clicking on a tab "A tab change results in a postback and the request lifecycle starts for the page, chart requests are also fired."
...and I don't believe I want chart requests to be fired if I'm not within (or am leaving), the charting tab. Hence my inability to leave that tab.
John
Portlet support for ChartCreator
Cagatay,
(I don't mean to be a pest. I've posted this question elsewhere but this thread seems to be the most relevant to my issue.)
It boils down to this: I am trying to deploy ChartCreator for a pie chart in a portlet (Liferay is the portal it's deployed in). The JSF portlet itself works and I haven't found anything suggesting I need to do anything special to get the chart to work and have followed all the instructions. My log comments clearly show that the chart creator "getPieDataset" is working, but the chart itself does not render (I get the space alloted but the chart itself does not appear, just the standard red 'x'). I'm have the ChartCreator, MyFaces and Commons jars in my WEB-INF\lib. Any idea what's gone wrong?
Again, my apologies if this is a duplicate question, it just seemed like it belongs here and I'm anxious to get this baby working since the demo .jar (and what folks have written here) clearly shows this is what I need for my project.
(I don't mean to be a pest. I've posted this question elsewhere but this thread seems to be the most relevant to my issue.)
It boils down to this: I am trying to deploy ChartCreator for a pie chart in a portlet (Liferay is the portal it's deployed in). The JSF portlet itself works and I haven't found anything suggesting I need to do anything special to get the chart to work and have followed all the instructions. My log comments clearly show that the chart creator "getPieDataset" is working, but the chart itself does not render (I get the space alloted but the chart itself does not appear, just the standard red 'x'). I'm have the ChartCreator, MyFaces and Commons jars in my WEB-INF\lib. Any idea what's gone wrong?
Again, my apologies if this is a duplicate question, it just seemed like it belongs here and I'm anxious to get this baby working since the demo .jar (and what folks have written here) clearly shows this is what I need for my project.
jmack
jmack@1800flowers.com
jmack@1800flowers.com
Cagatay,cagatay_civici wrote:It looks like there is an issue with these empty charts, soon I will post a sample example or a war file to show the usage of the component.For now; if the binding is something like then you must have defined;
datasource="#{someBean.dataSource}"
public DataSourceType getDataSource() {} in your managed bean. And the datasource type must be either DefaultCategoryDataet or DefaultPieDataset.You can see the manual in the rar file.
First I want to say that I really like this and I'm working to implement it now. It's a great component and very quick.

I have a managed bean that has a property based off of the following class:
Code: Select all
package com.citigroup.charts;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jfree.data.category.DefaultCategoryDataset;
import org.jfree.data.general.DefaultPieDataset;
public class ChartPage {
private DefaultPieDataset pieDataset = null;
private DefaultCategoryDataset barDataset = null;
private ArrayList groupBarDatasets = new ArrayList();
private Map statsMap = new HashMap();
private String pageName = "";
private static final Log log = LogFactory.getLog(ChartPage.class);
public ChartPage(String name, DefaultPieDataset pie, DefaultCategoryDataset bar, Map stats) {
pageName = name;
pieDataset = pie;
barDataset = bar;
statsMap = stats;
}
public ChartPage(String name, DefaultPieDataset pie, Map stats) {
pageName = name;
pieDataset = pie;
statsMap = stats;
}
public ChartPage(String name, DefaultCategoryDataset bar, Map stats) {
pageName = name;
barDataset = bar;
statsMap = stats;
}
public ChartPage(String name, ArrayList groupDatasets) {
groupBarDatasets = groupDatasets;
pageName = name;
}
public DefaultCategoryDataset getBarDataset() {
log.info("(barDataset == null) = " + (barDataset == null));
return barDataset;
}
public ArrayList getGroupBarDatasets() {
log.info("(groupBarDatasets == null) = " + (groupBarDatasets == null));
return groupBarDatasets;
}
public String getPageName() {
log.info("(pageName == null) = " + (pageName == null));
return pageName;
}
public DefaultPieDataset getPieDataset() {
log.info("(pieDataset == null) = " + (pieDataset == null));
if( pieDataset != null ) {
log.info("pieDataset.itemcount() = " + pieDataset.getItemCount());
}
return pieDataset;
}
public Map getStatsMap() {
log.info("(statsMap == null) = " + (statsMap == null));
return statsMap;
}
public void setBarDataset(DefaultCategoryDataset barDataset) {
this.barDataset = barDataset;
}
public void setGroupBarDatasets(ArrayList groupBarDatasets) {
this.groupBarDatasets = groupBarDatasets;
}
public void setPageName(String pageName) {
this.pageName = pageName;
}
public void setPieDataset(DefaultPieDataset pieDataset) {
this.pieDataset = pieDataset;
}
public void setStatsMap(Map statsMap) {
this.statsMap = statsMap;
}
}
Here is the part of my .jsp that displays the chart:
Code: Select all
<h:form id="appForm">
<div id="applicationPage" style="display: block;">
<h:dataTable id="appChart" border="1" value="#{dataGatherer.appChartPages}" var="appPage">
<h:column>
<h:panelGrid>
<h:outputText value="#{appPage.pageName} Inputs"></h:outputText>
<charts:chart id="chart" type="pie" datasource="#{appPage.pieDataset}" onclick="alert('pie chart clicked');"></charts:chart>
</h:panelGrid>
</h:column>
</h:dataTable>
</div>
</h:form>
Can you, or anyone else reading this, help me out and tell my what I'm doing wrong? I can give more information but please specify what you want me to give.
Thanks for any and all help!
Empty charts update
I downloaded the example WAR in my attempts to solve my problem with the charts not display, getting a red "X" instead, and it seems to work fine. I placed my class files and a new jsp file in this webapp, added a link to my jsp on the index.html screen, added a managed-bean to the faces-config.xml file and tested it out. These are the same class files and screen that are displaying only the red "X". Surprisingly in the example WAR this screen worked perfectly. So, I know that my code is accurate now.
So I created a new project with all of the same libraries as the example WAR, with the addition of log4j-1.2.12.jar for logging. The only class files in this project are the ones that I added to the example WAR. The only pages in this project are an index.html page and the one page that I added to the example WAR. I copied the web.xml and faces-config.xml file into my new project. I deleted all the managed beans except the one that I added, the only one that's needed. Finally I tested this new app. The page displayed showed the red "X"/empty chart instead of the actual charts. I have absolutely no idea why!!!!
I'm so frustrated!!!. I know it should work and there has to be something that is configured wrong but I just don't know what it could be.
Any suggestions would be great. I can send source code if you want.
I still think this is a good product, I just wish I could get it to work
So I created a new project with all of the same libraries as the example WAR, with the addition of log4j-1.2.12.jar for logging. The only class files in this project are the ones that I added to the example WAR. The only pages in this project are an index.html page and the one page that I added to the example WAR. I copied the web.xml and faces-config.xml file into my new project. I deleted all the managed beans except the one that I added, the only one that's needed. Finally I tested this new app. The page displayed showed the red "X"/empty chart instead of the actual charts. I have absolutely no idea why!!!!
I'm so frustrated!!!. I know it should work and there has to be something that is configured wrong but I just don't know what it could be.
Any suggestions would be great. I can send source code if you want.
I still think this is a good product, I just wish I could get it to work

RE:Empty charts update
I have figured out what the problem was but not why. The problem: there were 2 url-mapping patterns in the web.xml file. The first, ".faces", is the one that didn't work. The second, "/faces/*", is the one that works. I don't know why though. If anyone has an answer I'd like to know it.