Skip to content

Commit

Permalink
fix: remove bar chart sort to use data order
Browse files Browse the repository at this point in the history
  • Loading branch information
AlasDiablo committed Oct 17, 2023
1 parent 5fc9c76 commit 17103f4
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import {
AXIS_X,
AXIS_Y,
lodexDirectionToIdDirection,
lodexOrderToIdOrder,
lodexScaleToIdScale,
} from '../../../chartsUtils';
import VegaAdvancedMode from '../../../shared/VegaAdvancedMode';
Expand Down Expand Up @@ -89,7 +88,6 @@ const BarChartAdmin = props => {

const specBuilder = new BarChart();
specBuilder.setAxisDirection(lodexDirectionToIdDirection(direction));
specBuilder.setOrderBy(lodexOrderToIdOrder(params.orderBy));
specBuilder.setScale(lodexScaleToIdScale(scale));
specBuilder.setColor(colors);
specBuilder.setRoundValue(axisRoundValue);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import {
AXIS_X,
AXIS_Y,
lodexDirectionToIdDirection,
lodexOrderToIdOrder,
lodexScaleToIdScale,
VEGA_LITE_DATA_INJECT_TYPE_A,
} from '../../../chartsUtils';
Expand Down Expand Up @@ -64,7 +63,6 @@ const BarChartView = ({

specBuilder.setAxisDirection(lodexDirectionToIdDirection(direction));

specBuilder.setOrderBy(lodexOrderToIdOrder(params.orderBy));
specBuilder.setScale(lodexScaleToIdScale(scale));
specBuilder.setColor(colors);
specBuilder.setRoundValue(axisRoundValue);
Expand Down
37 changes: 4 additions & 33 deletions src/app/js/formats/vega-lite/models/BarChart.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,8 @@ import {
AXIS_VERTICAL,
AXIS_X,
AXIS_Y,
LABEL_ASC,
LABEL_DESC,
SCALE_LINEAR,
SCALE_LOG,
VALUES_ASC,
VALUES_DESC,
} from '../../chartsUtils';
import { VEGA_ACTIONS_WIDTH } from '../component/vega-lite-component/VegaLiteComponent';
import BasicChart from './BasicChart';
Expand Down Expand Up @@ -45,7 +41,6 @@ class BarChart extends BasicChart {
x: AXIS_NOMINAL,
y: AXIS_QUANTITATIVE,
};
this.orderBy = VALUES_ASC;
this.direction = AXIS_HORIZONTAL;
this.size = 20;
this.round = false;
Expand Down Expand Up @@ -154,14 +149,6 @@ class BarChart extends BasicChart {
}
}

/**
* Change the value order
* @param orderBy order wanted (use factoryUtils const) [default value: VALUES_ASC]
*/
setOrderBy(orderBy) {
this.orderBy = orderBy;
}

/**
* Change axis direction (swap x and y values)
* @param axisDirection direction wanted (use factoryUtils const) [default value: AXIS_VERTICAL]
Expand All @@ -187,26 +174,10 @@ class BarChart extends BasicChart {
model.encoding.x.axis.labelAngle = this.labelAngle.x;
model.encoding.y.axis.labelAngle = this.labelAngle.y;

switch (this.orderBy) {
case VALUES_ASC:
labelsModel.encoding.y.sort = model.encoding.x.sort =
this.direction === AXIS_VERTICAL ? 'y' : 'x';
break;
case VALUES_DESC:
labelsModel.encoding.y.sort = model.encoding.x.sort =
this.direction === AXIS_VERTICAL ? '-y' : '-x';
break;
case LABEL_ASC:
labelsModel.encoding.y.sort = model.encoding.x.sort =
this.direction === AXIS_VERTICAL ? 'x' : 'y';
break;
case LABEL_DESC:
labelsModel.encoding.y.sort = model.encoding.x.sort =
this.direction === AXIS_VERTICAL ? '-x' : '-y';
break;
default:
break;
}
labelsModel.encoding.x.sort = null;
labelsModel.encoding.y.sort = null;
model.encoding.x.sort = null;
model.encoding.y.sort = null;

if (this.labelOverlap) {
model.encoding.x.axis.labelOverlap = true;
Expand Down

0 comments on commit 17103f4

Please sign in to comment.