@hestia-earth/ui-components 0.41.29 → 0.41.31

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.
@@ -5654,7 +5654,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.6", ngImpor
5654
5654
  // show label 8px from bar
5655
5655
  const gapX = 8;
5656
5656
  const placementGap = (placement) => (placement === 'right' ? +gapX : -gapX);
5657
- const placementX = (x, chart, data, placement) => placement === 'right' ? (data < 0 ? positionAtZero(chart) : x) : x;
5657
+ const placementX = (x, chart, data, placement) => placement === 'right' ? (!Array.isArray(data) && data < 0 ? positionAtZero(chart) : x) : x;
5658
5658
  const positionAtZero = (chart) => chart.scales.x.getPixelForValue(0);
5659
5659
  const defaultBarDrawSettings = {
5660
5660
  placement: 'right',
@@ -5699,7 +5699,8 @@ const afterBarDrawPlugin = settings => ({
5699
5699
  const { x, y, base } = element;
5700
5700
  const label = chart.data.labels?.[index] ?? '';
5701
5701
  const data = dataset.data[index];
5702
- const anchorX = placement === 'left' ? base : x;
5702
+ // use min/max as both negative values would inverse the positions
5703
+ const anchorX = placement === 'left' ? Math.min(base, x) : Math.max(base, x);
5703
5704
  const xPos = xPosFn(anchorX, index, width, chart, data, placement);
5704
5705
  const yPos = yPosFn(y, index, height, chart, data, placement);
5705
5706
  const text = isUndefined(data) ? emptyValueLabel : textFn({ label, data }, index, chart);
@@ -6066,6 +6067,15 @@ const stretchSvg = (svgString, width, height) => {
6066
6067
  svgElement.setAttribute('preserveAspectRatio', 'xMidYMid meet');
6067
6068
  return svgElement.outerHTML;
6068
6069
  };
6070
+ const parseAfterDrawBarPlugins = (afterBarDrawConfig, units) => Array.isArray(afterBarDrawConfig)
6071
+ ? afterBarDrawConfig.map(afterBarDrawPlugin)
6072
+ : [
6073
+ afterBarDrawPlugin({
6074
+ textFn: ({ data }) => [toPrecision(Array.isArray(data) ? data[0] : data), units].filter(Boolean).join(' '),
6075
+ emptyValueLabel: 'No data',
6076
+ ...afterBarDrawConfig
6077
+ })
6078
+ ];
6069
6079
  const convertToSvg = (config, metadata = {}) => new Promise((resolve, reject) => {
6070
6080
  const width = metadata.width || defaultChartWidth;
6071
6081
  const height = metadata.height || defaultChartHeight;
@@ -6120,13 +6130,11 @@ const convertToSvg = (config, metadata = {}) => new Promise((resolve, reject) =>
6120
6130
  };
6121
6131
  // 4. Register Export-Specific Plugins
6122
6132
  chartConfig.plugins = [
6123
- afterBarDrawPlugin({
6124
- textFn: ({ data }) => [toPrecision(Array.isArray(data) ? data[0] : data), metadata.units].filter(Boolean).join(' '),
6125
- emptyValueLabel: 'No data',
6126
- ...(metadata?.afterBarDrawConfig || {})
6127
- }),
6133
+ ...parseAfterDrawBarPlugins(metadata.afterBarDrawConfig || {}, metadata.units),
6128
6134
  metadata.lollipopConfig ? lollipopChartPlugin(metadata.lollipopConfig) : null
6129
- ].filter(Boolean);
6135
+ ]
6136
+ .filter(Boolean)
6137
+ .flat();
6130
6138
  chart = new Chart(mockCanvas, chartConfig);
6131
6139
  });
6132
6140
  const exportAsSVG = async (config, metadata) => {