Skip to content

Commit

Permalink
Merge pull request #12 from processout/clickable-line-chart
Browse files Browse the repository at this point in the history
add onclick function for line chart
  • Loading branch information
julien-rodrigues-cko authored Feb 2, 2022
2 parents 95628c0 + 1930599 commit c9b7750
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/barlinechart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -507,6 +507,23 @@ export class BarLineChart extends Chart {
if (this.linesTooltip && vals.length > 0)
this.linesTooltip.hide.call(this, vals);
}.bind(this)
)
.on(
"click",
function (d) {
var vals: Array<any> = [];
for (var line of this.lines)
for (var val of line.data)
if (
((val.key instanceof Date &&
val.key.toString() == d.toString()) ||
val.key == d) &&
this.linesTooltip
)
vals.push(val);
for (var line of this.lines)
if (line.onclick) line.onclick(vals[0]);
}.bind(this)
);
}

Expand Down

0 comments on commit c9b7750

Please sign in to comment.