Skip to content

Commit

Permalink
Closes #359: Truncate x-axis by default.
Browse files Browse the repository at this point in the history
  • Loading branch information
Marina Samuel committed Apr 11, 2018
1 parent 595c1cf commit fe44f98
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
15 changes: 12 additions & 3 deletions client/app/visualizations/chart/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -251,9 +251,18 @@ function ChartEditor(ColorPalette, clientConfig) {
scope.options.legend = { enabled: true };
}

if (!has(scope.options, 'xAxisLabelLength')) {
scope.options.xAxisLabelLength = 300;
}
scope.$watch('options.globalSeriesType', (newType, oldType) => {
const defaultXAxisLength = 10;
if (!has(scope.options, 'xAxisLabelLength')) {
scope.options.xAxisLabelLength = defaultXAxisLength;
}
if (oldType !== newType) {
scope.options.xAxisLabelLength = defaultXAxisLength;
if (newType === 'pie') {
scope.options.xAxisLabelLength = 300;
}
}
}, true);

if (scope.columnNames) {
each(scope.options.columnMapping, (value, key) => {
Expand Down
3 changes: 2 additions & 1 deletion client/app/visualizations/chart/plotly/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,8 @@ function prepareChartData(seriesList, options) {
const yValues = [];
const yErrorValues = [];
each(data, (row) => {
const x = normalizeValue(row.x);
const xAxisLabelLength = parseInt(options.xAxisLabelLength, 10) || DEFAULT_XAXIS_LABEL_LENGTH;
const x = normalizeValue(row.x).substr(0, xAxisLabelLength);
const y = normalizeValue(row.y);
const yError = normalizeValue(row.yError);
sourceData.set(x, {
Expand Down

0 comments on commit fe44f98

Please sign in to comment.