improve time tick labels more
This commit is contained in:
@ -1413,12 +1413,12 @@ function Graph(gindex, container, x_label, y_label, tag, scaleType = "linear"){
|
|||||||
title: false, // former scaleLabel
|
title: false, // former scaleLabel
|
||||||
type: 'time',
|
type: 'time',
|
||||||
time: {
|
time: {
|
||||||
displayFormats: {'millisecond': 'HH:mm:ss.SSS', 'second': 'HH:mm:ss', 'minute': 'HH:mm','hour': 'EEE HH:mm', 'day': 'EEE dd.', 'week': 'MMM DD', 'month': 'MMM DD'},
|
displayFormats: {'millisecond': 'HH:mm:ss.SSS', 'second': 'HH:mm:ss', 'minute': 'HH:mm','hour': 'EEE d. HH:mm', 'day': 'EE d.', 'week': 'd. MMM yy', 'month': 'MMM yy'},
|
||||||
},
|
},
|
||||||
ticks: {
|
ticks: {
|
||||||
padding: -20,
|
padding: -20,
|
||||||
stepSize: 180000,
|
// stepSize: 180000,
|
||||||
//autoSkip: false,
|
autoSkip: true,
|
||||||
maxRotation: 0,
|
maxRotation: 0,
|
||||||
// callback not used, this is better done in afterBuildTicks
|
// callback not used, this is better done in afterBuildTicks
|
||||||
},
|
},
|
||||||
@ -1429,26 +1429,28 @@ function Graph(gindex, container, x_label, y_label, tag, scaleType = "linear"){
|
|||||||
first = ticks[0].value;
|
first = ticks[0].value;
|
||||||
step = ticks[1].value - first;
|
step = ticks[1].value - first;
|
||||||
offset = (first - axis._adapter.startOf(first, 'day')) % step;
|
offset = (first - axis._adapter.startOf(first, 'day')) % step;
|
||||||
let start = 0;
|
let result = [];
|
||||||
if (ticks[0].value - offset < axis.min) start = 1;
|
|
||||||
let v = axis.min;
|
let v = axis.min;
|
||||||
result = []; // [{value: v, major: false}];
|
for (tick of ticks) {
|
||||||
for (tick of ticks.slice(start)) {
|
|
||||||
v = tick.value - offset;
|
v = tick.value - offset;
|
||||||
|
if (v > axis.min + step / 2) {
|
||||||
result.push({value: v, major: false});
|
result.push({value: v, major: false});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
v += step;
|
v += step;
|
||||||
if (v < axis.max) result.push({value:v, major: false});
|
if (v < axis.max) result.push({value:v, major: false});
|
||||||
// result.push({value: axis.max, major: false});
|
|
||||||
axis.ticks = result;
|
axis.ticks = result;
|
||||||
// return result;
|
// return result;
|
||||||
},
|
},
|
||||||
afterTickToLabelConversion_disabled: function(axis) {
|
beforeFit: function(axis) { // called after ticks are autoskipped
|
||||||
|
prevday = '';
|
||||||
for (tick of axis.ticks) {
|
for (tick of axis.ticks) {
|
||||||
s = tick.label.split(' ');
|
s = tick.label.split(' ');
|
||||||
if (s.length == 3) { // dd MMM HH:mm format
|
if (s.length == 3) { // format with day
|
||||||
if (s[-1] == '00:00') {
|
// show date only on first label of a day
|
||||||
tick.label = s.slice(0,2).join(' '); // date
|
day = s.slice(0, 2).join(' ');
|
||||||
|
if (day != prevday) {
|
||||||
|
prevday = day;
|
||||||
} else {
|
} else {
|
||||||
tick.label = s[2]; // time
|
tick.label = s[2]; // time
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user