123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115 |
- <template>
- <div class="chinaMap">
- <div class="map" ref="MapMountNode"></div>
- </div>
- </template>
- <script>
- export default {
- props: ["listData"],
- data() {
- return {};
- },
- methods: {
- //先定义个方法
- myEcharts() {
- //把echarts绑定到显示元素上
- const myChart = this.$echarts.init(this.$refs.MapMountNode);
- //设置图表属性
- // 经营数据
- const option = {
- color: ["#91cc75"],
- title: {
- text: "产品数据",
- // textStyle: {
- // color: "#6d767e",
- // },
- },
- tooltip: {
- trigger: "axis",
- axisPointer: {
- type: "shadow",
- },
- },
- grid: {
- left: "3%",
- right: "4%",
- bottom: "3%",
- containLabel: true,
- },
- xAxis: [
- {
- type: "value",
- },
- ],
- yAxis: [
- {
- type: "category",
- axisTick: {
- show: false,
- },
- data: ["购买订单数", "购买人数", "购买金额"],
- },
- ],
- series: [
- {
- name: "数量",
- type: "bar",
- label: {
- show: true,
- position: "inside",
- },
- itemStyle: {
- normal: {
- label: {
- show: true, //开启显示数值
- position: "right", //数值在上方显示
- textStyle: {
- //数值样式
- color: "#9b9ca2", //字体颜色
- fontSize: 14, //字体大小
- },
- },
- },
- },
- emphasis: {
- focus: "series",
- },
- data: [
- this.listData.product_data.order,
- this.listData.product_data.people,
- this.listData.product_data.money,
- ],
- },
- ],
- };
- //数据绑定到表格
- myChart.setOption(option);
- window.addEventListener("resize", function () {
- myChart.resize(); //myChart指自己定义的echartsDom对象
- });
- },
- },
- // 监听父组件传过来的值的变化
- watch: {
- listData: {
- handler(val) {
- this.myEcharts();
- },
- },
- },
- mounted() {
- this.myEcharts();
- },
- };
- </script>
- <style scoped>
- .map {
- width: 99%;
- /* height: 280px; */
- height: 20vh;
- /* border: 1px solid saddlebrown; */
- }
- </style>
|