开发者

Used trinidad chart tag <tr:chart> in XHTML, but no output is coming

Below is the code where i am facing the issue, i am not getting the output of the graphs. Kindly help me.

My 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&开发者_运维知识库lt;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;

    }

}


It's mandatory to have a <h:head> in the template right before <h:body>. That's where all the JSF 2.x scripts and stylesheets end in. I won't be surprised if the <tr:chart> has some JS/CSS dependencies.


I was unable to get the graph in xhtml file, so i copied the same in jsp and got the graph.


I had a similar problem and solved it by adding the following lines to web.xml:

<mime-mapping>
   <extension>svg</extension>
   <mime-type>image/svg+xml</mime-type>
</mime-mapping>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜