import echarts from '@/static/js/echarts.js' // 引入文件
- <template>
- <view id="myChart">view>
- template>
- <script>
- import echarts from '@/static/js/echarts.js' // 引入文件
- export default {
- mounted() {
- // 初始化ECharts
- const myChart = echarts.init(document.getElementById('myChart'))
-
- // 进行图表的配置和数据处理
- myChart.setOption({
- title: {
- text: 'ECharts 入门示例'
- },
- tooltip: {},
- xAxis: {
- data: ['衬衫', '羊毛衫', '雪纺衫', '裤子', '高跟鞋', '袜子']
- },
- yAxis: {},
- series: [
- {
- name: '销量',
- type: 'bar',
- data: [5, 20, 36, 10, 10, 20]
- }
- ]
- })
- },
- data() {
- return {
-
- }
- },
- methods: {}
- }
- script>
- <style>
- #myChart {
- width: 400px;
- height: 300px;
- }
- style>
获取 ECharts - 入门篇 - Handbook - Apache ECharts
npm install echarts --save
import * as echarts from 'echarts';
const myChart = echarts.init(document.getElementById('myChart'))
- import * as echarts from 'echarts';
-
- // 基于准备好的dom,初始化echarts实例
- var myChart = echarts.init(document.getElementById('main'));
- // 绘制图表
- myChart.setOption({
- title: {
- text: 'ECharts 入门示例'
- },
- tooltip: {},
- xAxis: {
- data: ['衬衫', '羊毛衫', '雪纺衫', '裤子', '高跟鞋', '袜子']
- },
- yAxis: {},
- series: [
- {
- name: '销量',
- type: 'bar',
- data: [5, 20, 36, 10, 10, 20]
- }
- ]
- });