Here are the examples of the python api bokeh.models.tickers.DatetimeTicker taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
1 Examples
0
Source : plotters.py
with MIT License
from andyljones
with MIT License
from andyljones
def timedelta_xaxis(f):
f.xaxis.ticker = bom.tickers.DatetimeTicker()
f.xaxis.formatter = bom.FuncTickFormatter(code="""
// TODO: Add support for millis
// Calculate the hours, mins and seconds
var s = Math.floor(tick / 1e3);
var m = Math.floor(s/60);
var s = s - 60*m;
var h = Math.floor(m/60);
var m = m - 60*h;
var h = h.toString();
var m = m.toString();
var s = s.toString();
var pm = m.padStart(2, "0");
var ps = s.padStart(2, "0");
// Figure out what the min resolution is going to be
var min_diff = Infinity;
for (var i = 0; i < ticks.length-1; i++) {
min_diff = Math.min(min_diff, ticks[i+1]-ticks[i]);
}
if (min_diff < = 60e3) {
var min_res = 2;
} else if (min_diff < = 3600e3) {
var min_res = 1;
} else {
var min_res = 0;
}
// Figure out what the max resolution is going to be
if (ticks.length > 1) {
var max_diff = ticks[ticks.length-1] - ticks[0];
} else {
var max_diff = Infinity;
}
if (max_diff >= 3600e3) {
var max_res = 0;
} else if (max_diff >= 60e3) {
var max_res = 1;
} else {
var max_res = 2;
}
// Format the timedelta. Finally.
if ((max_res == 0) && (min_res == 0)) {
return `${h}h`;
} else if ((max_res == 0) && (min_res == 1)) {
return `${h}h${pm}`;
} else if ((max_res == 0) && (min_res == 2)) {
return `${h}h${pm}m${ps}`;
} else if ((max_res == 1) && (min_res == 1)) {
return `${m}m`;
} else if ((max_res == 1) && (min_res == 2)) {
return `${m}m${ps}`;
} else if ((max_res == 2) && (min_res == 2)) {
return `${s}s`;
}
""")
def suffix_yaxis(f):