Skip to content

Commit

Permalink
fix(speed-chart): format to human readable data
Browse files Browse the repository at this point in the history
  • Loading branch information
ElonH committed Jun 1, 2020
1 parent 0cb442d commit 5c3b532
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions src/app/pages/jobs/speed-chart/speed-chart.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { ChartDataSets, ChartOptions, ChartPoint } from 'chart.js';
import { Color, BaseChartDirective } from 'ng2-charts';
import * as moment from 'moment';
import { pairwise } from 'rxjs/operators';
import { FormatBytes } from 'src/app/utils/format-bytes';

@Component({
selector: 'jobs-speed-chart',
Expand Down Expand Up @@ -84,6 +85,21 @@ export class SpeedChartComponent implements OnInit {
hover: {
intersect: false,
},
tooltips: {
mode: 'index',
callbacks: {
label: function (tooltipItem, data) {
var label = data.datasets[tooltipItem.datasetIndex].label || '';
if (label) {
label += ': ';
}
if (typeof tooltipItem.yLabel === 'number')
label += FormatBytes(tooltipItem.yLabel, 3) + '/s';
else label += tooltipItem.yLabel;
return label;
},
},
},
scales: {
// We use this empty structure as a placeholder for dynamic theming.
xAxes: [
Expand Down Expand Up @@ -118,9 +134,13 @@ export class SpeedChartComponent implements OnInit {
},
ticks: {
labelOffset: -10, // sit on gridline
padding: -65, // moving label into dataset
// min: 0,
padding: -83, // moving label into dataset
min: 0,
beginAtZero: true,
callback: function (value) {
if (typeof value === 'number') return FormatBytes(value) + '/s';
return value;
},
},
scaleLabel: {
display: false,
Expand Down

0 comments on commit 5c3b532

Please sign in to comment.