Skip to content

Commit

Permalink
fix: better y-ticks for barplot
Browse files Browse the repository at this point in the history
  • Loading branch information
ErikBjare committed Jun 10, 2021
1 parent 0b4edeb commit fe54dcc
Showing 1 changed file with 16 additions and 14 deletions.
30 changes: 16 additions & 14 deletions src/visualizations/TimelineBarChart.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,20 @@ import { Bar } from 'vue-chartjs';
import { Vue, Component, Prop, Watch } from 'vue-property-decorator';
import { get_hour_offset } from '~/util/time';
function hourToTick(hours: number): string {
if (hours > 1) {
return `${hours}h`;
} else {
if (hours == 1) {
return '1h';
} else if (hours == 0) {
return '0';
} else {
return Math.round(hours * 60) + 'm';
}
}
}
@Component({
extends: Bar, // this is important to add the functionality to your component
})
Expand Down Expand Up @@ -60,13 +74,7 @@ export default class ChartTimelineBars extends Vue<Bar> {
stepSize: 0.25,
min: 0,
max: 1,
callback: function (value: number) {
if (value == 1) {
return '1h';
} else {
return Math.round(value * 60) + 'min';
}
},
callback: hourToTick,
},
},
];
Expand All @@ -77,13 +85,7 @@ export default class ChartTimelineBars extends Vue<Bar> {
ticks: {
stepSize: 1,
min: 0,
callback: function (value: number) {
if (value == 1) {
return '1h';
} else {
return Math.round(value) + 'h';
}
},
callback: hourToTick,
},
},
];
Expand Down

1 comment on commit fe54dcc

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here are screenshots of this commit:

Screenshots using aw-server v0.10.0 (click to expand)

Screenshots using aw-server-rust master (click to expand)

Screenshots using aw-server-rust v0.10.0 (click to expand)

CML watermark

Please sign in to comment.