@opendata-ai/openchart-vanilla 6.26.0 → 6.27.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
@@ -4414,6 +4414,9 @@ function renderChartSVG(layout, container, opts) {
4414
4414
  svg.style.height = `${height}px`;
4415
4415
  svg.setAttribute("role", layout.a11y.role);
4416
4416
  svg.setAttribute("aria-label", layout.a11y.altText);
4417
+ if (layout.display === "sparkline") {
4418
+ svg.setAttribute("data-display", "sparkline");
4419
+ }
4417
4420
  const classes = opts?.animate ? "oc-chart oc-animate" : "oc-chart";
4418
4421
  svg.setAttribute("class", classes);
4419
4422
  if (animation?.enabled) {
@@ -5813,6 +5816,20 @@ function createChart(container, spec, options) {
5813
5816
  }
5814
5817
  function getContainerDimensions() {
5815
5818
  const rect = container.getBoundingClientRect();
5819
+ const isSparkline = "display" in currentSpec && currentSpec.display === "sparkline";
5820
+ if (isSparkline) {
5821
+ let width = rect.width;
5822
+ let height = rect.height;
5823
+ if (!height && container.parentElement) {
5824
+ const parentRect = container.parentElement.getBoundingClientRect();
5825
+ height = parentRect.height;
5826
+ if (!width) width = parentRect.width;
5827
+ }
5828
+ return {
5829
+ width: Math.max(width || 200, 30),
5830
+ height: Math.max(height || 40, 20)
5831
+ };
5832
+ }
5816
5833
  return {
5817
5834
  width: Math.max(rect.width || 600, 100),
5818
5835
  height: Math.max(rect.height || 400, 100)
@@ -6074,7 +6091,7 @@ function createChart(container, spec, options) {
6074
6091
  }
6075
6092
  currentLayout = compile();
6076
6093
  const shouldAnimate = isFirstRender && !!currentLayout.animation?.enabled;
6077
- const crosshair = "crosshair" in currentSpec && !!currentSpec.crosshair;
6094
+ const crosshair = !!currentLayout.crosshair;
6078
6095
  svgElement = renderChartSVG(currentLayout, container, {
6079
6096
  animate: shouldAnimate,
6080
6097
  crosshair