123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206 |
- <template>
- <ve-map
- :height="options.height"
- :after-config="options.config"
- :data="datas"
- :settings="defaultSettings"
- :extend="defaultOptions">
- </ve-map>
- </template>
- <script>
- const mapJson = require('../../assets/js/china.json')
- console.log(mapJson)
- export default {
- name: 'chart',
- props: {
- id: String,
- datas: Object,
- options: {
- height: String,
- colors: Array || Object,
- settings: Object,
- config: Function
- }
- },
- data () {
- return {
- initRendererSvg: {
- renderer: 'svg'
- },
- defaultSettings: {
- // positionJsonLink: '/page_big_pc/assets/js/china.json',
- mapOrigin: mapJson,
- label: {
- show: true,
- fontSize: 12
- },
- selectedMode: false, // 去掉省份小圆点
- itemStyle: {
- normal: {
- borderColor: '#F06326',
- areaColor: '#FFFFFF'
- }
- },
- mapGrid: {
- left: 82,
- right: 82
- }
- },
- defaultOptions: {
- tooltip: {
- confine: true,
- backgroundColor: '#fff',
- axisPointer: {
- type: 'shadow',
- shadowStyle: {
- color: 'rgba(5,166,243,0.1)'
- },
- z: 3
- },
- textStyle: {
- color: '#171826',
- fontSize: 12
- },
- padding: [8, 12],
- extraCssText: 'box-shadow: 0px 4px 16px rgba(8, 31, 38, 0.08)',
- formatter: (params, ticket, callback) => {
- if (params.data === null) {
- return params.name + ':0'
- } else {
- return params.name + ':' + params.value
- }
- }
- },
- grid: {
- left: 32,
- right: 16,
- containLabel: true
- },
- legend: {
- selectedMode: false,
- textStyle: {
- color: 'transparent'
- },
- itemWidth: 0,
- itemHeight: 0
- },
- silent: false, // 禁用鼠标点击、滑过事件
- series: {
- showLegendSymbol: false,
- selectedMode: false
- },
- graphic: [
- {
- type: 'group',
- bottom: 42,
- children: [
- {
- type: 'text',
- z: 100,
- left: 'left',
- top: 'middle',
- style: {
- fill: '#333',
- text: '市场分布数量',
- font: '12px Microsoft YaHei'
- }
- }]
- },
- {
- type: 'rect',
- z: 101,
- left: 0,
- bottom: 16,
- shape: {
- width: 150,
- height: 24
- },
- style: {
- stroke: '#FB483D',
- fill: 'transparent',
- lineWidth: 0.5
- }
- },
- this.rectGroup(0, '#F06326'),
- this.rectGroup(25, '#F48A5D'),
- this.rectGroup(50, '#FFB366'),
- this.rectGroup(75, '#FFCF9F'),
- this.rectGroup(100, '#FFE7CF'),
- this.rectGroup(125, '#FFF4EB'),
- {
- type: 'group',
- width: 150,
- bottom: 0,
- left: 0,
- children: [{
- type: 'text',
- z: 100,
- left: 'left',
- top: 'middle',
- style: {
- fill: '#333',
- font: '12px Microsoft YaHei'
- }
- },
- {
- type: 'text',
- z: 100,
- left: 'right',
- top: 'middle',
- style: {
- fill: '#333',
- text: '0',
- font: '12px Microsoft YaHei'
- }
- }]
- }
- ],
- visualMap: {
- show: false,
- inRange: {
- color: ['#FFF4EB', '#FFE7CF', '#FFCF9F', '#FFB366', '#F48A5D', '#F06326']
- },
- outOfRange: {
- color: ['#F06326']
- }
- }
- }
- }
- },
- computed: {},
- watch: {},
- mounted () {},
- methods: {
- extend (chart) {
- chart.setOption({
- series: [{
- type: 'bar',
- barWidth: 20
- }, {
- type: 'line',
- smooth: false,
- symbol: 'none'
- }]
- })
- },
- rectGroup (left, color) {
- return {
- type: 'rect',
- z: 90,
- left: left,
- bottom: 16,
- shape: {
- width: 25,
- height: 24
- },
- style: {
- fill: color
- }
- }
- }
- },
- beforeDestroy () {}
- }
- </script>
- <style lang="scss" scoped>
- </style>
|