ecomfe / vue-echarts

Vue.js component for Apache ECharts™.
https://vue-echarts.dev
MIT License
9.61k stars 1.48k forks source link

图表大小怎么设置问题(我才入门vue,提的问题不周到,多包含) #97

Closed mengyou658 closed 7 years ago

mengyou658 commented 7 years ago

求指教一下,怎么设置才能成功,使用vue-cli生成的项目,添加的node-sass编译 这种形式引入

<template src="./Chart1.html"></template>
<style src="./Chart1.scss" module lang="scss"></style>
<script src="./Chart1js.js"></script>

Chart1.html内容:

<div class="chart">
  <chart :options="bar" auto-resize></chart>
</div>

Chart1.scss内容:

.echarts {
  width: 800px;
  height: 400px;
}

Chart1js.js内容:

import ECharts from 'vue-echarts/components/ECharts.vue'
import 'echarts/lib/chart/bar'
import 'echarts/lib/chart/line'
import 'echarts/lib/chart/pie'
import 'echarts/lib/chart/map'
import 'echarts/lib/chart/radar'
import 'echarts/lib/chart/scatter'
import 'echarts/lib/chart/effectScatter'
import 'echarts/lib/component/tooltip'
import 'echarts/lib/component/polar'
import 'echarts/lib/component/geo'
import 'echarts/lib/component/legend'
import 'echarts/lib/component/title'
import 'echarts/lib/component/visualMap'

import 'echarts-liquidfill'
// built-in theme
import 'echarts/theme/dark'

import {mapActions} from 'vuex'
export default {
  name: 'chart1',
  data () {
    return {
      bar: this.$store.state.chart1.bar
    }
  },
  components: {
    chart: ECharts
  },
  methods: {
    ...mapActions([
      'getDataRemote'
    ])
  },
  mounted: function () {
    this.$nextTick(function () {
      this.getDataRemote({
        dataType: 10,
        dateType: 3,
        anaType: 0,
        storeId: 0,
        startDate: '2017-06-23 00:00:00',
        endDate: '2017-06-23 14:00:00'
      })
    })
  }
}

最终展示的页面的outerHTML内容如下

忘记附上package.json 中的dependencies

  "dependencies": {
    "axios": "^0.16.2",
    "better-scroll": "^0.1.15",
    "echarts-liquidfill": "^1.0.5",
    "element-ui": "^1.3.6",
    "fastclick": "^1.0.6",
    "humps": "^2.0.0",
    "iscroll": "^5.2.0",
    "lodash": "^4.17.4",
    "moment": "^2.18.1",
    "showdown": "^1.6.4",
    "vue": "^2.3.3",
    "vue-echarts": "^2.4.0",
    "vue-router": "^2.3.1",
    "vuex": "^2.2.1"
  },
hzxie commented 7 years ago

所以你是怎么解决的呢?