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
|
||||
type: '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: {
|
||||
padding: -20,
|
||||
stepSize: 180000,
|
||||
//autoSkip: false,
|
||||
// stepSize: 180000,
|
||||
autoSkip: true,
|
||||
maxRotation: 0,
|
||||
// callback not used, this is better done in afterBuildTicks
|
||||
},
|
||||
@ -1429,30 +1429,32 @@ function Graph(gindex, container, x_label, y_label, tag, scaleType = "linear"){
|
||||
first = ticks[0].value;
|
||||
step = ticks[1].value - first;
|
||||
offset = (first - axis._adapter.startOf(first, 'day')) % step;
|
||||
let start = 0;
|
||||
if (ticks[0].value - offset < axis.min) start = 1;
|
||||
let result = [];
|
||||
let v = axis.min;
|
||||
result = []; // [{value: v, major: false}];
|
||||
for (tick of ticks.slice(start)) {
|
||||
for (tick of ticks) {
|
||||
v = tick.value - offset;
|
||||
result.push({value: v, major: false});
|
||||
if (v > axis.min + step / 2) {
|
||||
result.push({value: v, major: false});
|
||||
}
|
||||
}
|
||||
v += step;
|
||||
if (v < axis.max) result.push({value:v, major: false});
|
||||
// result.push({value: axis.max, major: false});
|
||||
axis.ticks = result;
|
||||
// return result;
|
||||
},
|
||||
afterTickToLabelConversion_disabled: function(axis) {
|
||||
beforeFit: function(axis) { // called after ticks are autoskipped
|
||||
prevday = '';
|
||||
for (tick of axis.ticks) {
|
||||
s = tick.label.split(' ');
|
||||
if (s.length == 3) { // dd MMM HH:mm format
|
||||
if (s[-1] == '00:00') {
|
||||
tick.label = s.slice(0,2).join(' '); // date
|
||||
} else {
|
||||
tick.label = s[2]; // time
|
||||
}
|
||||
}
|
||||
s = tick.label.split(' ');
|
||||
if (s.length == 3) { // format with day
|
||||
// show date only on first label of a day
|
||||
day = s.slice(0, 2).join(' ');
|
||||
if (day != prevday) {
|
||||
prevday = day;
|
||||
} else {
|
||||
tick.label = s[2]; // time
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
grid:{drawTicks:false},
|
||||
|
Reference in New Issue
Block a user