Jump to content
Software FX Community

Gantt chart Y-axis tick label iterartion with TagLib not working


Recommended Posts

It seems that I am not able to properly iterate over a bean provided lists of y-axis tick label names when generating a Gantt chart with the TagLib provided. In fact since the <axisY> element must be a direct descendant to <chart>, I see no way to programaticaly set the labels for the ticks in any manner.

 Snippet below:

<chartfx:chart height="280" width="450" gallery="GANTT">   <c:forEach items="${stackedBarChartBean.userInputs}" var="userInput" varStatus="userInputStatus">   <chartfx:axisY>   <chartfx:keyLabel>   <chartfx:label index="${userInputStatus.index}">   ${userInput}   </chartfx:label>   </chartfx:keyLabel>



Link to comment
Share on other sites

GabrielA was kind enough to post an entire set of chart examples in TagLib. This helps immensely. However, these examples do expose the limitations of the taglib not being able to generate charts from a dynamic set of data. I have attached (hopefully) a JSP using the TagLib that does NOT work due to the taglib's enforcement of hierarchy of its elements.

 As you will see, being unable to use the forEach tag limits the ability. Is this a bug or feature? 

Link to comment
Share on other sites

It is a design limitation, so I guess it is a "feature", you can not add any extra tag inside the chartfx tag. 

The best alternative is to use the listProvider.  Chart FX will loop throught the List and build the chart based on the its. This is a example (I'm sorry, I'm not taglib expert so the extra code is plain java):


java.util.List list1 = new java.util.ArrayList(5);






java.util.List list2 = new java.util.ArrayList(5);

list2.add(new Integer(20));

list2.add(new Integer(30));

list2.add(new Integer(20));

list2.add(new Integer(50));

list2.add(new Integer(40));

java.util.List list3 = new java.util.ArrayList(5);

list3.add(new Integer(50));

list3.add(new Integer(40));

list3.add(new Integer(50));

list3.add(new Integer(60));

list3.add(new Integer(30));

java.util.List list4 = new java.util.ArrayList();






<chartfx:chart height="240" width="400" rightGap="30">


  <chartfx:listProvider list="points"/>



You may be able to give your bean object directly to the listProvider.  Try with simple chart first, just passing some data to see if it works, then you can use the dataType to specify how you want the data to be handled, i.e INI_VALUE, XVALUE, LABEL, etc.


Link to comment
Share on other sites

I've actually made some inroads with getting access to the data from the Bean into the sets of the dataValue element. It's not pretty, but it is dynamic nonetheless.  I guess I'd now like to file a formal bug report regarding the taglib not being able to live alongside core JSTL elements. How is that done?

Taking a que from the taglib examples prodived, I now have whittled the tick label issue down to the following:


  <chartfx:chart height="280" width="450" gallery="GANTT">   <chartfx:axisCollection>   <chartfx:axis index="2">   <chartfx:labels>

<%-- A forEach loop needs to start here so I can iterate over index and label values from a call to a Bean object --%>   <chartfx:label index="${varStatus.index}" label="${var}"/>

<%-- And end here --%>   </chartfx:labels>   </chartfx:axis>   </chartfx:axisCollection>



Link to comment
Share on other sites

  • 2 years later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...