• Post Reply Bookmark Topic Watch Topic
  • New Topic

Used trinidad chart tag tr:chart in xhtml file, but no output is coming.  RSS feed

 
Vinay karthik
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I am new to JSF, we are using JSF 2.0 along with trinidad 1.2 in xhtml fileusing JSF 2.0 along with trinidad 1.2 in xhtml file, my requirement is to display some graphs,but i am not getting the output.I searched in google but it didn't help me. Below is the code.
Kindly help me.

xhtml code

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:tr="http://myfaces.apache.org/trinidad">

<h:body>
<h1>Director Screen</h1>
<tr:document>
<tr:form>
<tr:chart value="#{chartBean}" type="pie" />
<tr:chart value="#{chartBean}" type="bar" />
<tr:chart value="#{chartBean}" type="circularGauge" />
</tr:form>
</tr:document>
</h:body>
</html>

Java code

package com;

import java.util.ArrayList;
import java.util.List;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;

import org.apache.myfaces.trinidad.model.ChartModel;

@ManagedBean(name = "chartBean")
@SessionScoped
public class ChartBean extends ChartModel {

@Override
public List<String> getGroupLabels() {
List<String> groupLabels = new ArrayList<String>();
groupLabels.add("Java");
groupLabels.add("Linux");
groupLabels.add(".NET");
return groupLabels;
}

@Override
public List<String> getSeriesLabels() {
List<String> seriesLabels = new ArrayList<String>();
seriesLabels.add("Love it");
seriesLabels.add("Hate it");
return seriesLabels;
}

@Override
public List<List<Double>> getYValues() {

List<List<Double>> chartValues = new ArrayList<List<Double>>();
// Fill the groups
for (int i = 0; i < getGroupLabels().size(); i++) {
List<Double> numbers = new ArrayList<Double>();

// fill the series per group
for (int j = 0; j < getSeriesLabels().size(); j++) {
numbers.add(100* Math.random());
}
chartValues.add(numbers);
}
return chartValues;

}

}
 
Vinay karthik
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I finally got it, by using jsp instead of xhtml.
I copied the code from xhtml and put it in jsp and am able to get the graph.

Thank You
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!