@gravity-ui/charts 1.34.10 → 1.35.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ascending, descending, sort } from 'd3';
|
|
1
|
+
import { ascending, descending, reverse, sort } from 'd3';
|
|
2
2
|
import get from 'lodash/get';
|
|
3
3
|
import { getDataCategoryValue, getLabelsSize } from '../../../utils';
|
|
4
4
|
import { getFormattedValue } from '../../../utils/chart/format';
|
|
@@ -103,9 +103,13 @@ export const prepareBarXData = async (args) => {
|
|
|
103
103
|
let positiveStackHeight = 0;
|
|
104
104
|
let negativeStackHeight = 0;
|
|
105
105
|
const stackItems = [];
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
106
|
+
let sortedData = yValues;
|
|
107
|
+
if (sortKey) {
|
|
108
|
+
sortedData = sort(yValues, (a, b) => comparator(get(a, sortKey), get(b, sortKey)));
|
|
109
|
+
}
|
|
110
|
+
else if ((sortingOptions === null || sortingOptions === void 0 ? void 0 : sortingOptions.direction) === 'desc') {
|
|
111
|
+
sortedData = reverse(yValues);
|
|
112
|
+
}
|
|
109
113
|
for (let yValueIndex = 0; yValueIndex < sortedData.length; yValueIndex++) {
|
|
110
114
|
const yValue = sortedData[yValueIndex];
|
|
111
115
|
const yAxisIndex = yValue.series.yAxis;
|
|
@@ -119,7 +123,6 @@ export const prepareBarXData = async (args) => {
|
|
|
119
123
|
if (xAxis.type === 'category') {
|
|
120
124
|
const xBandScale = xScale;
|
|
121
125
|
const xBandScaleDomain = xBandScale.domain();
|
|
122
|
-
// eslint-disable-next-line max-depth
|
|
123
126
|
if (xBandScaleDomain.indexOf(xValue) === -1) {
|
|
124
127
|
continue;
|
|
125
128
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ascending, descending, sort } from 'd3';
|
|
1
|
+
import { ascending, descending, reverse, sort } from 'd3';
|
|
2
2
|
import get from 'lodash/get';
|
|
3
3
|
import { getDataCategoryValue, getLabelsSize } from '../../../utils';
|
|
4
4
|
import { getFormattedValue } from '../../../utils/chart/format';
|
|
@@ -103,9 +103,13 @@ export const prepareBarXData = async (args) => {
|
|
|
103
103
|
let positiveStackHeight = 0;
|
|
104
104
|
let negativeStackHeight = 0;
|
|
105
105
|
const stackItems = [];
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
106
|
+
let sortedData = yValues;
|
|
107
|
+
if (sortKey) {
|
|
108
|
+
sortedData = sort(yValues, (a, b) => comparator(get(a, sortKey), get(b, sortKey)));
|
|
109
|
+
}
|
|
110
|
+
else if ((sortingOptions === null || sortingOptions === void 0 ? void 0 : sortingOptions.direction) === 'desc') {
|
|
111
|
+
sortedData = reverse(yValues);
|
|
112
|
+
}
|
|
109
113
|
for (let yValueIndex = 0; yValueIndex < sortedData.length; yValueIndex++) {
|
|
110
114
|
const yValue = sortedData[yValueIndex];
|
|
111
115
|
const yAxisIndex = yValue.series.yAxis;
|
|
@@ -119,7 +123,6 @@ export const prepareBarXData = async (args) => {
|
|
|
119
123
|
if (xAxis.type === 'category') {
|
|
120
124
|
const xBandScale = xScale;
|
|
121
125
|
const xBandScaleDomain = xBandScale.domain();
|
|
122
|
-
// eslint-disable-next-line max-depth
|
|
123
126
|
if (xBandScaleDomain.indexOf(xValue) === -1) {
|
|
124
127
|
continue;
|
|
125
128
|
}
|