| <!DOCTYPE html> | |
| <!-- | |
| Licensed to the Apache Software Foundation (ASF) under one | |
| or more contributor license agreements. See the NOTICE file | |
| distributed with this work for additional information | |
| regarding copyright ownership. The ASF licenses this file | |
| to you under the Apache License, Version 2.0 (the | |
| "License"); you may not use this file except in compliance | |
| with the License. You may obtain a copy of the License at | |
| http://www.apache.org/licenses/LICENSE-2.0 | |
| Unless required by applicable law or agreed to in writing, | |
| software distributed under the License is distributed on an | |
| "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | |
| KIND, either express or implied. See the License for the | |
| specific language governing permissions and limitations | |
| under the License. | |
| --> | |
| <html> | |
| <head> | |
| <meta charset="utf-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1" /> | |
| <script src="lib/dat.gui.min.js"></script> | |
| <link rel="stylesheet" href="lib/reset.css" /> | |
| </head> | |
| <body> | |
| <style> | |
| body { | |
| background: #eee; | |
| margin: 0; | |
| text-align: center; | |
| } | |
| #main { | |
| box-sizing: border-box; | |
| margin: 0 auto; | |
| width: 800px; | |
| max-width: 100%; | |
| text-align: center; | |
| } | |
| .chart { | |
| height: 400px; | |
| border-radius: 5px; | |
| margin: 20px 0; | |
| box-shadow: 0 0 10px rgba(0, 0, 0, 0.2); | |
| background: #fff; | |
| } | |
| </style> | |
| <div id="main"> | |
| <h1>Tests ESM lib files importing in browser partially</h1> | |
| </div> | |
| <script type="importmap"> | |
| { | |
| "imports": { | |
| "echarts/": "../", | |
| "zrender/": "../node_modules/zrender/", | |
| "tslib": "../node_modules/tslib/tslib.es6.js" | |
| } | |
| } | |
| </script> | |
| <script> | |
| if (typeof process === 'undefined' || !process.env) { | |
| window.process = { | |
| env: { | |
| NODE_ENV: 'development' | |
| } | |
| }; | |
| } | |
| </script> | |
| <script type="module"> | |
| import * as echarts from 'echarts/core.js'; | |
| import { PieChart } from 'echarts/charts.js'; | |
| import { CanvasRenderer } from 'echarts/renderers.js'; | |
| echarts.use([PieChart, CanvasRenderer]) | |
| const chartsOptions = [{ | |
| series: [{ | |
| type: 'pie', | |
| data: [{ | |
| name: 'A', | |
| value: 5 | |
| }, { | |
| name: 'B', | |
| value: 3 | |
| }, { | |
| name: 'C', | |
| value: 1 | |
| }] | |
| }] | |
| }] | |
| const charts = []; | |
| chartsOptions.forEach(function (chartOption) { | |
| const dom = document.createElement('div'); | |
| dom.className = 'chart'; | |
| document.querySelector('#main').appendChild(dom); | |
| const chart = echarts.init(dom); | |
| chart.setOption(chartOption); | |
| }); | |
| </script> | |
| </body> | |
| </html> | |