[英]ECharts from Baidu
有誰知道 Echarts ( http://echarts.baidu.com ) 的例子:
所有 Echarts 示例都非常好地呈現,但沒有示例顯示如何在本地(英語)部署和運行它(這很重要)實際工作。
從我的許多“復制和粘貼”然后編輯工作中,我得到了無盡的文件未找到消息和到處都是神秘字符(公平地說,它們是漢字,但我只將它們視為神秘的波浪線)。 我也下載了 github sampes 並搜索了谷歌,但沒有成功。
圖書館看起來非常棒,但我無法破譯它:(
一個單獨的 .jsp 英文頁面示例(有效)會很棒。 有誰知道我在哪里可以找到一個?
謝謝
我知道已經有一個可以接受的答案,但我想我會為閱讀這個問題的人添加一個鏈接。
echarts 文檔的新版本(撰寫本文時為 echarts 3.4.0)已轉換為英文。
他們擁有所有文檔,包括選項、api 代碼、下載和許多英文示例(帶有 codepen 類型的開發區域,您可以測試您的選項並實時查看結果)。
入口頁面可以在這里找到:
https://ecomfe.github.io/echarts-doc/public/en/
該庫可以在這里下載:
https://ecomfe.github.io/echarts-doc/public/en/download.html
可以在此處找到入門教程:
ecomfe.github.io/echarts-doc/public/en/tutorial.html
可以在此處找到多種選項:
ecomfe.github.io/echarts-doc/public/en/option.html
可以在此處找到大量示例:
ecomfe.github.io/echarts-examples/public/index.html
一個簡單的條形圖示例及其 codepen 操場可以在這里找到:ecomfe.github.io/echarts-examples/public/editor.html?c=bar-tick-align
下面我將他們簡單的條形圖粘貼到窗口中以供您查看:
<!DOCTYPE html> <html> <head> <script type="text/javascript" src="http://echarts.baidu.com/gallery/vendors/echarts/echarts-all-3.js"></script> </head> <body> <div id="container" style="width: 600px; height: 250px;"></div> <script type="text/javascript"> var chart = document.getElementById("container"); var myChart = echarts.init(chart); var option = { title: { text: "Echarts Bar Chart" }, legend: [ { data: ["Hours Worked"] } ], tooltip: { trigger: 'axis', axisPointer: { type: 'shadow' } }, xAxis: [ { type: 'category', data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'], axisTick: { alignWithLabel: true } } ], yAxis: [ { type: 'value' } ], series: [ { name:'Hours Worked', type:'bar', barWidth: '60%', data: [10, 52, 200, 334, 390, 330, 220] } ] }; myChart.setOption(option, true); </script> </body> </html>
這是一個簡單有效的示例。 只需將其保存到 HTML 文件中,然后將其呈現到您的瀏覽器中即可。 無需下載或配置任何其他內容。 它使用遠程腳本文件,沒有中文文本:
<!doctype html> <html> <head> <title>ECharts Sample</title> <script src="https://cdnjs.cloudflare.com/ajax/libs/echarts/4.6.0/echarts-en.min.js"></script> </head> <body> <div id="chart" style="width: 500px; height: 350px;"></div> <script> var chart = document.getElementById('chart'); var myChart = echarts.init(chart); var option = { title: { text: 'ECharts Sample' }, 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] }] }; myChart.setOption(option); </script> </body> </html>
他們的github中有一個例子清楚地解釋了使用圖表的方式我只是測試它,它工作得很好
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>ECharts</title>
</head>
<body>
<!--Step:1 Prepare a dom for ECharts which (must) has size (width & hight)-->
<!--Step:1 為ECharts准備一個具備大小(寬高)的Dom-->
<div id="main" style="height:500px;border:1px solid #ccc;padding:10px;"></div>
<div id="mainMap" style="height:500px;border:1px solid #ccc;padding:10px;"></div>
<!--Step:2 Import echarts-all.js-->
<!--Step:2 引入echarts-all.js-->
<script src="js/echarts-all.js"></script>
<script type="text/javascript">
// Step:3 echarts & zrender as a Global Interface by the echarts-plain.js.
// Step:3 echarts和zrender被echarts-plain.js寫入為全局接口
var myChart = echarts.init(document.getElementById('main'));
myChart.setOption({
tooltip : {
trigger: 'axis'
},
legend: {
data:['蒸發量','降水量']
},
toolbox: {
show : true,
feature : {
mark : {show: true},
dataView : {show: true, readOnly: false},
magicType : {show: true, type: ['line', 'bar']},
restore : {show: true},
saveAsImage : {show: true}
}
},
calculable : true,
xAxis : [
{
type : 'category',
data : ['1月','2月','3月','4月','5月','6月','7月','8月','9月','10月','11月','12月']
}
],
yAxis : [
{
type : 'value',
splitArea : {show : true}
}
],
series : [
{
name:'蒸發量',
type:'bar',
data:[2.0, 4.9, 7.0, 23.2, 25.6, 76.7, 135.6, 162.2, 32.6, 20.0, 6.4, 3.3]
},
{
name:'降水量',
type:'bar',
data:[2.6, 5.9, 9.0, 26.4, 28.7, 70.7, 175.6, 182.2, 48.7, 18.8, 6.0, 2.3]
}
]
});
// --- 地圖 ---
var myChart2 = echarts.init(document.getElementById('mainMap'));
myChart2.setOption({
tooltip : {
trigger: 'item',
formatter: '{b}'
},
series : [
{
name: '中國',
type: 'map',
mapType: 'china',
selectedMode : 'multiple',
itemStyle:{
normal:{label:{show:true}},
emphasis:{label:{show:true}}
},
data:[
{name:'廣東',selected:true}
]
}
]
});
</script>
</body>
</html>
ECharts 確實提供了他們網站的英文版本,包括示例和文檔,根據您的問題,我猜您沒有看到。
https://ecomfe.github.io/echarts/index-en.html
(在此編輯時,他們需要將他們的英文文檔更新為 echarts 3.0 版本)。
https://ecomfe.github.io/echarts/doc/example-en.html
話雖如此,有時您仍希望整個 .js 及其默認字符串都是英文的,但 Google 翻譯可以提供幫助。
如果有人想知道。 有人確實將他們的整個 .js 翻譯成英文,以便按鈕和控件以英文顯示。 這家伙還要求他們將他的“英文”版本合並到 github 上,但我猜他們還不感興趣。
我已經測試了他的 js 文件,它是英文的。 zip 文件的鏈接也包含在那里。 但以防萬一它可以在這里找到 - 下載
數據顯示為中文,代碼結構和框架為英文。忽略具體數據,盡量放一些你想顯示的數據。
英文惡魔: http : //echarts.baidu.com/echarts2/doc/example-en.html
如果有人使用 echarts-for-react,我是這樣解決的
toolbox: {
show: true,
orient: 'vertical',
feature: {
dataView: { show: true, title: 'Data View', readOnly: false },
restore: { show: true, title: 'Reset' },
saveAsImage: { show: true, title: "Download" }
},
}
神奇之處在於 toolbox.feature.title
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.