Skip to content

Commit

Permalink
Fix bug: Tooltip not appearing for certain points (swimlane#501)
Browse files Browse the repository at this point in the history
This fixes an issue where the tooltip would not appear for certain data
points. I had thirty data points in a line chart, and the tooltip was
not working for points 2-9. Looking further, I noticed that the array
of points along the x axis was not being sorted in the correct order.
The numbers were being sorted in alphabetical order (which explains why
10 came after 1), so I added a compare function in the related sorts to
sort the number in xSet numerically.
  • Loading branch information
danloveg authored and marjan-georgiev committed Oct 3, 2017
1 parent faefb58 commit 18b010e
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/area-chart/area-chart-normalized.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,8 @@ export class AreaChartNormalizedComponent extends BaseChartComponent {
const min = Math.min(...values);
const max = Math.max(...values);
domain = [min, max];
this.xSet = [...values].sort();
// Use compare function to sort numbers numerically
this.xSet = [...values].sort((a, b) => (a - b));
} else {
domain = values;
this.xSet = values;
Expand Down
3 changes: 2 additions & 1 deletion src/area-chart/area-chart-stacked.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,8 @@ export class AreaChartStackedComponent extends BaseChartComponent {
: Math.max(...values);

domain = [min, max];
this.xSet = [...values].sort();
// Use compare function to sort numbers numerically
this.xSet = [...values].sort((a, b) => (a - b));
} else {
domain = values;
this.xSet = values;
Expand Down
3 changes: 2 additions & 1 deletion src/area-chart/area-chart.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,8 @@ export class AreaChartComponent extends BaseChartComponent {
: Math.max(...values);

domain = [min, max];
this.xSet = [...values].sort();
// Use compare function to sort numbers numerically
this.xSet = [...values].sort((a, b) => (a - b));
} else {
domain = values;
this.xSet = values;
Expand Down
3 changes: 2 additions & 1 deletion src/line-chart/line-chart.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,8 @@ export class LineChartComponent extends BaseChartComponent {
: Math.max(...values);

domain = [min, max];
this.xSet = [...values].sort();
// Use compare function to sort numbers numerically
this.xSet = [...values].sort((a, b) => (a - b));
} else {
domain = values;
this.xSet = values;
Expand Down

0 comments on commit 18b010e

Please sign in to comment.