mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 01:38:56 -04:00
[TSVB] Wrong x-axis formatting if "dateFormat" configuration property is not specified (#84899)
* [TSVB] Wrong x-axis formatting if "dateFormat" configuration property is not specified * Update create_xaxis_formatter.js Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
parent
9d6d78320b
commit
71f863ef66
2 changed files with 3 additions and 7 deletions
|
@ -18,18 +18,18 @@
|
|||
*/
|
||||
|
||||
import moment from 'moment';
|
||||
export function getFormat(interval, rules, dateFormat) {
|
||||
|
||||
function getFormat(interval, rules = []) {
|
||||
for (let i = rules.length - 1; i >= 0; i--) {
|
||||
const rule = rules[i];
|
||||
if (!rule[0] || interval >= moment.duration(rule[0])) {
|
||||
return rule[1];
|
||||
}
|
||||
}
|
||||
return dateFormat;
|
||||
}
|
||||
|
||||
export function createXaxisFormatter(interval, rules, dateFormat) {
|
||||
return (val) => {
|
||||
return moment(val).format(getFormat(interval, rules, dateFormat));
|
||||
return moment(val).format(getFormat(interval, rules) ?? dateFormat);
|
||||
};
|
||||
}
|
||||
|
|
|
@ -46,10 +46,6 @@ class TimeseriesVisualization extends Component {
|
|||
dateFormat = this.props.getConfig('dateFormat');
|
||||
|
||||
xAxisFormatter = (interval) => (val) => {
|
||||
if (!this.scaledDataFormat || !this.dateFormat) {
|
||||
return val;
|
||||
}
|
||||
|
||||
const formatter = createXaxisFormatter(interval, this.scaledDataFormat, this.dateFormat);
|
||||
return formatter(val);
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue