簡體   English   中英

如何在Liferay7中使用Echarts3(百度提供的圖表工具)?

[英]how to use Echarts3(a charts tool by baidu) in Liferay7?

我需要在Liferay7中使用圖表工具,然后老板建議使用Echarts3,這是百度提供的免費圖表庫,但是,Liferay使用Jsp,而echarts使用js,因此如何將js導入jsp以及如何在Liferay中設置相關屬性7? 這是echarts3演示:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>ECharts</title>
<!-- including ECharts file -->
<script src="echarts.js"></script>
</head>
<body>
<!-- prepare a DOM container with width and height -->
<div id="main" style="width: 600px;height:400px;"></div>
<script type="text/javascript">
    // based on prepared DOM, initialize echarts instance
    var myChart = echarts.init(document.getElementById('main'));

    // specify chart configuration item and data
    var option = {
        title: {
            text: 'ECharts entry example'
        },
        tooltip: {},
        legend: {
            data:['Sales']
        },
        xAxis: {
            data: ["shirt","cardign","chiffon shirt","pants","heels","socks"]
        },
        yAxis: {},
        series: [{
            name: 'Sales',
            type: 'bar',
            data: [5, 20, 36, 10, 10, 20]
        }]
    };

    // use configuration item and data specified to show chart
    myChart.setOption(option);
</script>

5分鍾即可開始使用ECharts

這不是Liferay甚至JSP所特有的(適用於所使用的任何表示層)。為了使我們的應用程序更加用戶友好和交互,許多預構建的javascript插件廣泛可用。為了將其用於我們的目的,我們需要為他們提供必要的數據以及DOM元素(主要是div或class),以便他們向最終用戶顯示交互式結構。 一旦您完成配置所需的步驟,便可以有效地集成許多其他圖表框架,例如Chart JsGoogle Charts 對於eChart,您需要包括給定的JS,提供DOM元素,最后從JSP提供必要的數據。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM