Skip to content

Commit

Permalink
fix:(bar) edp963#1713
Browse files Browse the repository at this point in the history
  • Loading branch information
ruanhan committed May 19, 2020
1 parent 1a2d367 commit d9287a5
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion webapp/app/containers/Widget/render/chart/bar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ export default function (chartProps: IChartProps, drillOptions) {
const stackOption = turnOnStack
? { stack: getStackName(m.name, stackConfig) }
: null

if (color.items.length) {
const sumArr = []
Object.entries(percentGrouped).forEach(([k, v]: [string, any[]]) => {
Expand Down Expand Up @@ -326,6 +327,7 @@ export default function (chartProps: IChartProps, drillOptions) {
if (acc[stackName]) {
return acc
}

acc[stackName] = {
name: stackName,
type: 'bar',
Expand All @@ -342,7 +344,15 @@ export default function (chartProps: IChartProps, drillOptions) {
formatter: (params) => {
let val = series
.filter((s) => s.stack === stackName)
.reduce((acc, s) => acc + s.data[params.dataIndex], 0)
.reduce((acc, s) => {
const dataIndex = params.dataIndex
if (typeof s.data[dataIndex] === 'number') {
return acc + s.data[params.dataIndex]
} else {
const { value } = s.data[dataIndex]
return acc + value
}
}, 0)
let format = metrics[serieIdx].format
if (percentage) {
format = {
Expand Down

0 comments on commit d9287a5

Please sign in to comment.