Skip to content

Commit eb1b3cb

Browse files
author
Marina Samuel
committed
Closes #359: Truncate x-axis by default.
1 parent 30be3e7 commit eb1b3cb

2 files changed

Lines changed: 14 additions & 4 deletions

File tree

client/app/visualizations/chart/index.js

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -251,9 +251,18 @@ function ChartEditor(ColorPalette, clientConfig) {
251251
scope.options.legend = { enabled: true };
252252
}
253253

254-
if (!has(scope.options, 'xAxisLabelLength')) {
255-
scope.options.xAxisLabelLength = 300;
256-
}
254+
scope.$watch('options.globalSeriesType', (newType, oldType) => {
255+
const defaultXAxisLength = 10;
256+
if (!has(scope.options, 'xAxisLabelLength')) {
257+
scope.options.xAxisLabelLength = defaultXAxisLength;
258+
}
259+
if (oldType !== newType) {
260+
scope.options.xAxisLabelLength = defaultXAxisLength;
261+
if (newType === 'pie') {
262+
scope.options.xAxisLabelLength = 300;
263+
}
264+
}
265+
}, true);
257266

258267
if (scope.columnNames) {
259268
each(scope.options.columnMapping, (value, key) => {

client/app/visualizations/chart/plotly/utils.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,8 @@ function prepareChartData(seriesList, options) {
230230
const yValues = [];
231231
const yErrorValues = [];
232232
each(data, (row) => {
233-
const x = normalizeValue(row.x);
233+
const xAxisLabelLength = parseInt(options.xAxisLabelLength, 10) || DEFAULT_XAXIS_LABEL_LENGTH;
234+
const x = normalizeValue(row.x).substr(0, xAxisLabelLength);
234235
const y = normalizeValue(row.y);
235236
const yError = normalizeValue(row.yError);
236237
sourceData.set(x, {

0 commit comments

Comments
 (0)