mirror of
https://github.com/getredash/redash.git
synced 2026-03-22 10:00:17 -04:00
* getredash/redash#2629 Refactor Chart visualization, add option for handling NULL values (keep/convert to 0.0) * Handle null values in line/area stacking code; some cleanup * Handle edge case: line/area stacking when last value of one of series is missing * Mjnor update to line/area stacking code * Fix line/area normalize to percents feature * Unit tests * Refine tests; add tests for prepareLayout function * Tests for prepareData (heatmap) function * Tests for prepareData (pie) function * Tests for prepareData (bar, line, area) function * Tests for prepareData (scatter, bubble) function * Tests for prepareData (box) function * Remove unused file
26 lines
807 B
JavaScript
26 lines
807 B
JavaScript
import { isUndefined } from 'lodash';
|
|
import moment from 'moment';
|
|
import plotlyCleanNumber from 'plotly.js/src/lib/clean_number';
|
|
|
|
export function cleanNumber(value) {
|
|
return isUndefined(value) ? value : plotlyCleanNumber(value);
|
|
}
|
|
|
|
export function getSeriesAxis(series, options) {
|
|
const seriesOptions = options.seriesOptions[series.name] || { type: options.globalSeriesType };
|
|
if ((seriesOptions.yAxis === 1) && (!options.series.stacking || (seriesOptions.type === 'line'))) {
|
|
return 'y2';
|
|
}
|
|
return 'y';
|
|
}
|
|
|
|
export function normalizeValue(value, axisType, dateTimeFormat = 'YYYY-MM-DD HH:mm:ss') {
|
|
if (axisType === 'datetime' && moment.utc(value).isValid()) {
|
|
value = moment.utc(value);
|
|
}
|
|
if (moment.isMoment(value)) {
|
|
return value.format(dateTimeFormat);
|
|
}
|
|
return value;
|
|
}
|