start-en.html 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  6. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  7. <meta name="description" content="ECharts">
  8. <meta name="author" content="kener.linfeng@gmail.com">
  9. <title>ECharts · Start</title>
  10. <link rel="shortcut icon" href="./asset/ico/favicon.png">
  11. <link href="./asset/css/font-awesome.min.css" rel="stylesheet">
  12. <link href="./asset/css/bootstrap.css" rel="stylesheet">
  13. <link href="./asset/css/carousel.css" rel="stylesheet">
  14. <link href="./asset/css/echartsHome.css" rel="stylesheet">
  15. <!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->
  16. <!--[if lt IE 9]>
  17. <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
  18. <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
  19. <![endif]-->
  20. <script src="./asset/js/google-code-prettify.js"></script>
  21. <link href="./asset/css/google-code-prettify.css" rel="stylesheet" />
  22. <link href="./asset/css/monokai.css" rel="stylesheet">
  23. <style type="text/css">
  24. .nav-tabs.nav-justified > .active > a, .nav-tabs.nav-justified > .active > a:hover {
  25. background-color:rgb(247, 247, 247);
  26. font-weight: bolder;
  27. }
  28. .tab-content {
  29. padding:20px;
  30. border-left: 1px solid #dddddd;
  31. border-right: 1px solid #dddddd;
  32. border-top: 0px;
  33. }
  34. </style>
  35. </head>
  36. <body onload="prettyPrint()">
  37. <!-- Fixed navbar -->
  38. <div class="navbar navbar-default navbar-fixed-top" role="navigation" id="head"></div>
  39. <div class="container">
  40. <h2 class="text-center">5 minutes to your first chart</h2>
  41. <ul class="nav nav-tabs nav-justified">
  42. <li class="active">
  43. <a id = "o-aqi" href="#main0" data-toggle="tab">modular single file import (preferred)</a></li>
  44. <li><a id = "o-pm25" href="#main1" data-toggle="tab">plain single file import</a></li>
  45. </ul>
  46. <div class="tab-content">
  47. <div class="tab-pane active" id="main0">
  48. <b class="title">1, Creat a echarts.html file. Prepare a Dom with size (width and height) for ECharts.</b>
  49. <pre class="prettyprint"><xmp><!DOCTYPE html>
  50. <head>
  51. <meta charset="utf-8">
  52. <title>ECharts</title>
  53. </head>
  54. <body>
  55. <!-- Prepare a Dom with size (width and height) for ECharts -->
  56. <div id="main" style="height:400px"></div>
  57. </body></xmp></pre>
  58. <b class="title">2, Create a &lt; script &gt; tag to include echarts' core file, echarts.js. </ b></b>
  59. <pre class="prettyprint"><xmp><!DOCTYPE html>
  60. <head>
  61. <meta charset="utf-8">
  62. <title>ECharts</title>
  63. </head>
  64. <body>
  65. <!-- Prepare a Dom with size (width and height) for ECharts -->
  66. <div id="main" style="height:400px"></div>
  67. <!-- ECharts import -->
  68. <script src="http://echarts.baidu.com/build/dist/echarts.js"></script>
  69. </body></xmp></pre>
  70. <b class="title">3, Create a new &lt; script &gt; tag, configure for module loader a path of echarts and the chart you need (the relative path is to link from the current page to echarts.js). For imported chart file, refer to <a href="doc-en.html#Import-ECharts2" target="_blank">Import ECharts2</a></b>
  71. <pre class="prettyprint"><xmp><!DOCTYPE html>
  72. <head>
  73. <meta charset="utf-8">
  74. <title>ECharts</title>
  75. </head>
  76. <body>
  77. <!-- Prepare a Dom with size (width and height) for ECharts -->
  78. <div id="main" style="height:400px"></div>
  79. <!-- ECharts import -->
  80. <script src="http://echarts.baidu.com/build/dist/echarts.js"></script>
  81. <script type="text/javascript">
  82. // configure for module loader
  83. require.config({
  84. paths: {
  85. echarts: 'http://echarts.baidu.com/build/dist'
  86. }
  87. });
  88. </script>
  89. </body></xmp></pre>
  90. <b class="title">4, Dynamically load echarts and the chart you need in the &lt; script &gt; tag. Use callback function to initialize and drive the generation of charts. For option, refer to <a href="doc-en.html#Option" target="_blank">API &amp; Doc</a></b>
  91. <pre class="prettyprint"><xmp><!DOCTYPE html>
  92. <head>
  93. <meta charset="utf-8">
  94. <title>ECharts</title>
  95. </head>
  96. <body>
  97. <!-- Prepare a Dom with size (width and height) for ECharts -->
  98. <div id="main" style="height:400px"></div>
  99. <!-- ECharts import -->
  100. <script src="http://echarts.baidu.com/build/dist/echarts.js"></script>
  101. <script type="text/javascript">
  102. // configure for module loader
  103. require.config({
  104. paths: {
  105. echarts: 'http://echarts.baidu.com/build/dist'
  106. }
  107. });
  108. // use
  109. require(
  110. [
  111. 'echarts',
  112. 'echarts/chart/bar' // require the specific chart type
  113. ],
  114. function (ec) {
  115. // Initialize after dom ready
  116. var myChart = ec.init(document.getElementById('main'));
  117. var option = {
  118. tooltip: {
  119. show: true
  120. },
  121. legend: {
  122. data:['Sales']
  123. },
  124. xAxis : [
  125. {
  126. type : 'category',
  127. data : ["Shirts", "Sweaters", "Chiffon Shirts", "Pants", "High Heels", "Socks"]
  128. }
  129. ],
  130. yAxis : [
  131. {
  132. type : 'value'
  133. }
  134. ],
  135. series : [
  136. {
  137. "name":"Sales",
  138. "type":"bar",
  139. "data":[5, 20, 40, 10, 10, 20]
  140. }
  141. ]
  142. };
  143. // Load data into the ECharts instance
  144. myChart.setOption(option);
  145. }
  146. );
  147. </script>
  148. </body></xmp></pre>
  149. <b>5, Open echarts.html in the browser to see the following results.</b>
  150. </div>
  151. <!------------------------------>
  152. <div class="tab-pane" id="main1">
  153. <b class="title">1, Creat a echarts.html file. Prepare a Dom with size (width and height) for ECharts.</b>
  154. <pre class="prettyprint"><xmp><!DOCTYPE html>
  155. <head>
  156. <meta charset="utf-8">
  157. <title>ECharts</title>
  158. </head>
  159. <body>
  160. <!-- Prepare a Dom with size (width and height) for ECharts -->
  161. <div id="main" style="height:400px"></div>
  162. </body></xmp></pre>
  163. <b class="title">2, Create a &lt; script &gt; tag to import echarts-plain.js. For the imported chart file, refer to<a href="doc-en.html#Import-ECharts3" target="_blank">Import ECharts3</a></b>
  164. <pre class="prettyprint"><xmp><!DOCTYPE html>
  165. <head>
  166. <meta charset="utf-8">
  167. <title>ECharts</title>
  168. </head>
  169. <body>
  170. <!-- Prepare a Dom with size (width and height) for ECharts -->
  171. <div id="main" style="height:400px"></div>
  172. <!-- ECharts import -->
  173. <script src="http://echarts.baidu.com/build/dist/echarts-all.js"></script>
  174. </body></xmp></pre>
  175. <b class="title">3, Create a &lt;script&gt; tag. Use global variable echarts to initialize and drive the generation of charts. For option, refer to<a href="doc-en.html#Option" target="_blank">API & Doc</a></b>
  176. <pre class="prettyprint"><xmp><!DOCTYPE html>
  177. <head>
  178. <meta charset="utf-8">
  179. <title>ECharts</title>
  180. </head>
  181. <body>
  182. <!-- Prepare a Dom with size (width and height) for ECharts -->
  183. <div id="main" style="height:400px"></div>
  184. <!-- ECharts import -->
  185. <script src="http://echarts.baidu.com/build/dist/echarts-all.js"></script>
  186. <script type="text/javascript">
  187. // Initialize after dom ready
  188. var myChart = echarts.init(document.getElementById('main'));
  189. var option = {
  190. tooltip: {
  191. show: true
  192. },
  193. legend: {
  194. data:['Sales']
  195. },
  196. xAxis : [
  197. {
  198. type : 'category',
  199. data : ["Shirts", "Sweaters", "Chiffon Shirts", "Pants", "High Heels", "Socks"]
  200. }
  201. ],
  202. yAxis : [
  203. {
  204. type : 'value'
  205. }
  206. ],
  207. series : [
  208. {
  209. "name":"Sales",
  210. "type":"bar",
  211. "data":[5, 20, 40, 10, 10, 20]
  212. }
  213. ]
  214. };
  215. // Load data into the ECharts instance
  216. myChart.setOption(option);
  217. </script>
  218. </body></xmp></pre>
  219. <b>4, Open echarts.html in the browser to see the following results.</b>
  220. </div>
  221. </div>
  222. <div id="main" style="height:400px;border: 1px solid #dddddd;border-top-width:0"></div>
  223. <div class="row" style="margin: 35px 0;">
  224. <h2>Best Reference Resource: Instances</h2>
  225. <p>ECharts is a data-driven chart. Since your main concern is how to achieve that option, we offer you, right here on our official website, an extensive <a href="./doc-en.html">documentation</a> for your reference and over 100 ready-made <a href="./example-en.html">demos</a> with the most core option code that is free to edit online. For ECharts, play makes perfect; hope you enjoy playing here.</p>
  226. </div>
  227. </div>
  228. <script src="../build/dist/echarts.js"></script>
  229. <script type="text/javascript">
  230. require.config({
  231. paths: {
  232. echarts: '../build/dist'
  233. }
  234. });
  235. require(
  236. [
  237. 'echarts',
  238. 'echarts/chart/bar'
  239. ],
  240. function (ec) {
  241. var myChart = ec.init(document.getElementById('main'));
  242. myChart.setOption(option);
  243. }
  244. );
  245. var option = {
  246. tooltip: {
  247. show: true
  248. },
  249. legend: {
  250. data:['Sales']
  251. },
  252. xAxis : [
  253. {
  254. type : 'category',
  255. data : ["Shirts", "Sweaters", "Chiffon Shirts", "Pants", "High Heels", "Socks"]
  256. }
  257. ],
  258. yAxis : [
  259. {
  260. type : 'value'
  261. }
  262. ],
  263. series : [
  264. {
  265. "name":"Sales",
  266. "type":"bar",
  267. "data":[5,20,40,10,10,20]
  268. }
  269. ]
  270. };
  271. </script>
  272. <footer id="footer"></footer>
  273. <!-- Le javascript
  274. ================================================== -->
  275. <!-- Placed at the end of the document so the pages load faster -->
  276. <script src="./asset/js/jquery.min.js"></script>
  277. <script type="text/javascript" src="./asset/js/echartsHome.js"></script>
  278. <script src="./asset/js/bootstrap.min.js"></script>
  279. </body>
  280. </html>