feat: 饼图、气泡图优化

This commit is contained in:
junjie 2021-08-18 15:43:18 +08:00
parent ec0b8bf7e9
commit 4b2ef13bef
2 changed files with 15 additions and 1 deletions

View File

@ -715,6 +715,12 @@ export const BASE_TREEMAP = {
{ {
// name: '', // name: '',
type: 'treemap', type: 'treemap',
itemStyle: {
gapWidth: 2
},
breadcrumb: {
show: false
},
// radius: ['0%', '60%'], // radius: ['0%', '60%'],
// avoidLabelOverlap: false, // avoidLabelOverlap: false,
// emphasis: { // emphasis: {

View File

@ -1,6 +1,8 @@
import { hexColorToRGBA } from '@/views/chart/chart/util' import { hexColorToRGBA } from '@/views/chart/chart/util'
import { componentStyle } from '../common/common' import { componentStyle } from '../common/common'
let bubbleArray = []
export function baseScatterOption(chart_option, chart) { export function baseScatterOption(chart_option, chart) {
// 处理shape attr // 处理shape attr
let customAttr = {} let customAttr = {}
@ -21,6 +23,7 @@ export function baseScatterOption(chart_option, chart) {
if (chart.data) { if (chart.data) {
chart_option.title.text = chart.title chart_option.title.text = chart.title
chart_option.xAxis.data = chart.data.x chart_option.xAxis.data = chart.data.x
bubbleArray = []
for (let i = 0; i < chart.data.series.length; i++) { for (let i = 0; i < chart.data.series.length; i++) {
const y = chart.data.series[i] const y = chart.data.series[i]
// color // color
@ -33,6 +36,9 @@ export function baseScatterOption(chart_option, chart) {
const extBubble = JSON.parse(chart.extBubble) const extBubble = JSON.parse(chart.extBubble)
if (extBubble && extBubble.length > 0) { if (extBubble && extBubble.length > 0) {
y.data.forEach(ele => {
bubbleArray.push(ele.value[2])
})
y.symbolSize = funcSize y.symbolSize = funcSize
} else { } else {
y.symbolSize = customAttr.size.scatterSymbolSize ? customAttr.size.scatterSymbolSize : 20 y.symbolSize = customAttr.size.scatterSymbolSize ? customAttr.size.scatterSymbolSize : 20
@ -53,5 +59,7 @@ export function baseScatterOption(chart_option, chart) {
} }
const funcSize = function(data) { const funcSize = function(data) {
return data[2] const k = 100
const max = Math.max(...bubbleArray)
return (data[2] / max) * k
} }