@redsift/charts 11.0.0 → 11.0.1

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.
package/index.js CHANGED
@@ -2120,21 +2120,23 @@ const RenderedLinearBarChart = /*#__PURE__*/forwardRef((props, ref) => {
2120
2120
  if (xScaleType === 'number') {
2121
2121
  if (currentKeyA < currentKeyB) return -1;
2122
2122
  if (currentKeyA > currentKeyB) return 1;
2123
- return hasCategory ? a.key[1] < b.key[1] ? 1 : -1 : 0;
2124
2123
  } else if (xScaleType === 'dateString') {
2125
2124
  if (Date.parse(currentKeyA) < Date.parse(currentKeyB)) return -1;
2126
2125
  if (Date.parse(currentKeyA) > Date.parse(currentKeyB)) return 1;
2127
- return hasCategory ? a.key[1] < b.key[1] ? 1 : -1 : 0;
2128
2126
  } else if (xScaleType === 'Date') {
2129
2127
  if (currentKeyA.valueOf() < currentKeyB.valueOf()) return -1;
2130
2128
  if (currentKeyA.valueOf() > currentKeyB.valueOf()) return 1;
2131
- return hasCategory ? a.key[1] < b.key[1] ? 1 : -1 : 0;
2132
2129
  } else if (xScaleType === 'string' && xAxisTickValues && Array.isArray(xAxisTickValues)) {
2133
2130
  if (xAxisTickValues.indexOf(currentKeyA) < xAxisTickValues.indexOf(currentKeyB)) return -1;
2134
2131
  if (xAxisTickValues.indexOf(currentKeyA) > xAxisTickValues.indexOf(currentKeyB)) return 1;
2135
- return hasCategory ? a.key[1] < b.key[1] ? 1 : -1 : 0;
2136
2132
  }
2137
- return hasCategory ? a.key[1] < b.key[1] ? 1 : -1 : 0;
2133
+ return hasCategory ? getSortingMethod(sortingMethod !== null && sortingMethod !== void 0 ? sortingMethod : 'asc-key')({
2134
+ key: a.key[1],
2135
+ value: a.value
2136
+ }, {
2137
+ key: b.key[1],
2138
+ value: b.value
2139
+ }) : 0;
2138
2140
  }), d => d.value !== null), (previousValue, currentValue, currentIndex) => {
2139
2141
  var _key$;
2140
2142
  const currentKeyD = hasCategory ? currentValue.key[0] : currentValue.key;
@@ -2164,7 +2166,7 @@ const RenderedLinearBarChart = /*#__PURE__*/forwardRef((props, ref) => {
2164
2166
  const minimalGap = Math.min(...bars.map((bar, i) => i > 0 ? Math.abs(bar.key - bars[i - 1].key) : undefined).filter(k => k)) * 0.9;
2165
2167
  barWidth = Math.min(barWidth, chartWidth / ((scaleX.domain()[1] - scaleX.domain()[0]) / minimalGap), chartWidth / (xAxisTickValues && typeof xAxisTickValues !== 'string' ? typeof xAxisTickValues === 'number' ? xAxisTickValues : Array.isArray(xAxisTickValues) ? xAxisTickValues.length : xAxisTickValues.range(scaleX.domain()[0], scaleX.domain()[1]).length : 1));
2166
2168
  }
2167
- const categories = [];
2169
+ const categories = sortingMethod && Array.isArray(sortingMethod) ? sortingMethod : [];
2168
2170
  const pivotedTable = bars.reduce((acc, item) => {
2169
2171
  const {
2170
2172
  key,