Skip to content

Commit

Permalink
fix(pie): support multi pie item
Browse files Browse the repository at this point in the history
  • Loading branch information
Melon committed Nov 2, 2018
1 parent 6cab8ac commit 0a99bd2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
14 changes: 6 additions & 8 deletions src/packages/pie/main.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { itemPoint } from '../../constants'
import { getFormated } from '../../utils'
import { getFormated, setArrayValue } from '../../utils'
import { cloneDeep } from 'utils-lite'

const pieRadius = 100
Expand Down Expand Up @@ -33,16 +33,14 @@ function getPieSeries (args) {
let rowsTemp = []
if (level) {
level.forEach((levelItems, index) => {
levelItems.forEach(item => { levelTemp[item] = index })
levelItems.forEach(item => { setArrayValue(levelTemp, item, index) })
})
innerRows.forEach(row => {
const itemLevel = levelTemp[row[dimension]]
if (itemLevel !== undefined) {
if (rowsTemp[itemLevel]) {
rowsTemp[itemLevel].push(row)
} else {
rowsTemp[itemLevel] = [row]
}
if (itemLevel && itemLevel.length) {
itemLevel.forEach(levelItem => {
setArrayValue(rowsTemp, levelItem, row)
})
}
})
} else {
Expand Down
8 changes: 8 additions & 0 deletions src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,3 +103,11 @@ export const getAmap = (key, v) => {
}
return amapPromise
}

export function setArrayValue (arr, index, value) {
if (arr[index] !== undefined) {
arr[index].push(value)
} else {
arr[index] = [value]
}
}

0 comments on commit 0a99bd2

Please sign in to comment.