Skip to content

Commit

Permalink
fix #2251 - pie chart dataPointIndex when clicked
Browse files Browse the repository at this point in the history
  • Loading branch information
junedchhipa committed May 10, 2024
1 parent 549da15 commit ef72843
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
10 changes: 4 additions & 6 deletions src/charts/Pie.js
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ class Pie {
w.config.plotOptions.pie.expandOnClick &&
this.chartType !== 'polarArea'
) {
elPath.click(this.pieClicked.bind(this, i))
elPath.node.addEventListener('mouseup', this.pieClicked.bind(this, i))
}

if (
Expand Down Expand Up @@ -614,6 +614,8 @@ class Pie {
pieSlice.setAttribute('d', origPath)
}
})
w.globals.capturedDataPointIndex = i

elPath.attr('data:pieClicked', 'true')
}

Expand Down Expand Up @@ -729,11 +731,7 @@ class Pie {
const gCircles = graphics.group()
const gYAxis = graphics.group()

const yScale = scale.niceScale(
0,
Math.ceil(this.maxY),
0
)
const yScale = scale.niceScale(0, Math.ceil(this.maxY), 0)

const yTexts = yScale.result.reverse()
let len = yScale.result.length
Expand Down
8 changes: 5 additions & 3 deletions src/modules/Events.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,10 @@ export default class Events {
event,
(e) => {
const opts = Object.assign({}, w, {
seriesIndex: w.globals.capturedSeriesIndex,
dataPointIndex: w.globals.capturedDataPointIndex
seriesIndex: w.globals.axisCharts
? w.globals.capturedSeriesIndex
: 0,
dataPointIndex: w.globals.capturedDataPointIndex,
})

if (e.type === 'mousemove' || e.type === 'touchmove') {
Expand All @@ -88,7 +90,7 @@ export default class Events {

this.ctx.eventList.forEach((event) => {
w.globals.dom.baseEl.addEventListener(event, this.documentEvent, {
passive: true
passive: true,
})
})

Expand Down

0 comments on commit ef72843

Please sign in to comment.