@opendata-ai/openchart-engine 6.16.0 → 6.17.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.
package/dist/index.js CHANGED
@@ -7776,9 +7776,9 @@ import {
7776
7776
  formatNumber as formatNumber6
7777
7777
  } from "@opendata-ai/openchart-core";
7778
7778
  var TICK_COUNTS = {
7779
- full: 10,
7780
- reduced: 7,
7781
- minimal: 3
7779
+ full: 12,
7780
+ reduced: 8,
7781
+ minimal: 4
7782
7782
  };
7783
7783
  var HEIGHT_MINIMAL_THRESHOLD = 120;
7784
7784
  var HEIGHT_REDUCED_THRESHOLD = 200;
@@ -8804,6 +8804,20 @@ function computeLegend(spec, strategy, theme, chartArea, watermark = true) {
8804
8804
  };
8805
8805
  }
8806
8806
  let entries = extractColorEntries(spec, theme);
8807
+ const isLineOrArea = spec.markType === "line" || spec.markType === "area";
8808
+ const hasLabels = spec.labels.density !== "none";
8809
+ const labelsWillRender = strategy.labelMode !== "none";
8810
+ const hasColorEncoding = spec.encoding.color != null;
8811
+ const legendNotForced = spec.legend?.show !== true;
8812
+ if (isLineOrArea && hasLabels && labelsWillRender && hasColorEncoding && legendNotForced) {
8813
+ const isArea = spec.markType === "area";
8814
+ const quantChannel = spec.encoding.y?.type === "quantitative" ? spec.encoding.y : spec.encoding.x;
8815
+ const stackValue2 = quantChannel?.stack;
8816
+ const isStacked = stackValue2 !== null && stackValue2 !== false;
8817
+ if (!isArea || !isStacked) {
8818
+ entries = [];
8819
+ }
8820
+ }
8807
8821
  const labelStyle = {
8808
8822
  fontFamily: theme.fonts.family,
8809
8823
  fontSize: theme.fonts.sizes.small,
@@ -9935,12 +9949,16 @@ function computeCategoryColors(data, column, theme, darkMode) {
9935
9949
  }
9936
9950
  bg = explicitMap[key];
9937
9951
  isExplicit = true;
9938
- } else if (autoAssigned.has(key)) {
9939
- bg = autoAssigned.get(key);
9952
+ } else if (column.autoAssign) {
9953
+ if (autoAssigned.has(key)) {
9954
+ bg = autoAssigned.get(key);
9955
+ } else {
9956
+ bg = categoricalPalette[nextPaletteIndex % categoricalPalette.length];
9957
+ nextPaletteIndex++;
9958
+ autoAssigned.set(key, bg);
9959
+ }
9940
9960
  } else {
9941
- bg = categoricalPalette[nextPaletteIndex % categoricalPalette.length];
9942
- nextPaletteIndex++;
9943
- autoAssigned.set(key, bg);
9961
+ continue;
9944
9962
  }
9945
9963
  if (darkMode && !isExplicit) {
9946
9964
  bg = adaptColorForDarkMode(bg, lightBg, darkBg);