echarts3中使用字符云报错_Echarts系列(二):vue2.0使用echarts3&&实现中国地图&&字符云...

这篇博客展示了如何利用ECharts库生成一个中国地图,地图上的各个省份用不同的颜色和数值表示订单量。代码中详细配置了地图的样式、提示信息、图例、数据范围、工具箱和缩放控制器等选项,随机生成了各省份的订单量数据,提供了一种数据可视化的实现方式。
摘要由CSDN通过智能技术生成

除了这一步操作,其他跟上边操作一样,option配置项改成地图就行,代码:

let option = {

title: {

text: '订单量',

subtext: '纯属虚构',

x: 'center'

},

tooltip: {

trigger: 'item'

},

legend: {

orient: 'vertical',

x: 'left',

data: ['订单量']

},

dataRange: {

x: 'left',

y: 'bottom',

splitList: [

{ start: 1500 },

{ start: 900, end: 1500 },

{ start: 310, end: 1000 },

{ start: 200, end: 300 },

{ start: 10, end: 200, label: '10 到 200(自定义label)' },

{ start: 5, end: 5, label: '5(自定义特殊颜色)', color: 'black' },

{ end: 10 }

],

color: ['#E0022B', '#E09107', '#A3E00B']

},

toolbox: {

show: true,

orient: 'vertical',

x: 'right',

y: 'center',

feature: {

mark: { show: true },

dataView: { show: true, readOnly: false },

restore: { show: true },

saveAsImage: { show: true }

}

},

roamController: {

show: true,

x: 'right',

mapTypeControl: {

'china': true

}

},

series: [

{

name: '订单量',

type: 'map',

mapType: 'china',

roam: false,

itemStyle: {

normal: {

label: {

show: true,

textStyle: {

color: "rgb(249, 249, 249)"

}

}

},

emphasis: { label: { show: true } }

},

data: [

{ name: '北京', value: Math.round(Math.random() * 2000) },

{ name: '天津', value: Math.round(Math.random() * 2000) },

{ name: '上海', value: Math.round(Math.random() * 2000) },

{ name: '重庆', value: Math.round(Math.random() * 2000) },

{ name: '河北', value: 0 },

{ name: '河南', value: Math.round(Math.random() * 2000) },

{ name: '云南', value: 5 },

{ name: '辽宁', value: 305 },

{ name: '黑龙江', value: Math.round(Math.random() * 2000) },

{ name: '湖南', value: 200 },

{ name: '安徽', value: Math.round(Math.random() * 2000) },

{ name: '山东', value: Math.round(Math.random() * 2000) },

{ name: '新疆', value: Math.round(Math.random() * 2000) },

{ name: '江苏', value: Math.round(Math.random() * 2000) },

{ name: '浙江', value: Math.round(Math.random() * 2000) },

{ name: '江西', value: Math.round(Math.random() * 2000) },

{ name: '湖北', value: Math.round(Math.random() * 2000) },

{ name: '广西', value: Math.round(Math.random() * 2000) },

{ name: '甘肃', value: Math.round(Math.random() * 2000) },

{ name: '山西', value: Math.round(Math.random() * 2000) },

{ name: '内蒙古', value: Math.round(Math.random() * 2000) },

{ name: '陕西', value: Math.round(Math.random() * 2000) },

{ name: '吉林', value: Math.round(Math.random() * 2000) },

{ name: '福建', value: Math.round(Math.random() * 2000) },

{ name: '贵州', value: Math.round(Math.random() * 2000) },

{ name: '广东', value: Math.round(Math.random() * 2000) },

{ name: '青海', value: Math.round(Math.random() * 2000) },

{ name: '西藏', value: Math.round(Math.random() * 2000) },

{ name: '四川', value: Math.round(Math.random() * 2000) },

{ name: '宁夏', value: Math.round(Math.random() * 2000) },

{ name: '海南', value: Math.round(Math.random() * 2000) },

{ name: '台湾', value: Math.round(Math.random() * 2000) },

{ name: '香港', value: Math.round(Math.random() * 2000) },

{ name: '澳门', value: Math.round(Math.random() * 2000) }

]

}

]

};

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
要在 Vue 使用高德地图echarts,需要先安装相应的依赖库。在命令行输入以下命令: ``` npm install echarts --save npm install echarts-gl --save npm install vue-amap --save ``` 安装完成后,可以在 Vue 组件使用这些库。以下是一个简单的示例: ```html <template> <div> <div ref="mapContainer" style="width: 100%; height: 400px;"></div> <div ref="chartContainer" style="width: 100%; height: 400px;"></div> </div> </template> <script> import VueAMap from 'vue-amap' import echarts from 'echarts' import 'echarts-gl' export default { name: 'MapChart', data() { return { map: null, chart: null, } }, mounted() { // 初始化高德地图 VueAMap.initAMapApiLoader({ key: 'YOUR_AMAP_KEY', plugin: ['AMap.Scale', 'AMap.OverView', 'AMap.ToolBar', 'AMap.MapType', 'AMap.Geolocation'], v: '1.4.4', }) this.$nextTick(() => { this.map = new VueAMap.AMap.Map(this.$refs.mapContainer, { zoom: 14, center: [116.39, 39.9], }) }) // 初始化 echarts this.$nextTick(() => { this.chart = echarts.init(this.$refs.chartContainer) this.chart.setOption({ // echarts 配置 series: [ { type: 'bar3D', data: [...], }, ], }) }) }, } </script> ``` 在这个示例,我们通过 VueAMap 的 `initAMapApiLoader` 方法初始化了高德地图,并在 `mounted` 钩子函数创建了一个地图实例。同时,我们通过 echarts 的 `init` 方法初始化了一个图表,并在 `mounted` 钩子函数设置了图表的配置项。 需要注意的是,在 `mounted` 钩子函数创建地图和图表的实例时,需要使用 `this.$nextTick` 方法,以确保在组件渲染完毕后再进行初始化操作。 以上是一个简单的示例,具体的实现方式还需要根据具体的业务需求进行调整。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值