vue-chrts 0.0.106 → 0.0.107

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,21 +1,25 @@
1
- import { BulletLegendItemInterface } from '@unovis/ts';
1
+ import { BulletLegendItemInterface, Orientation } from '@unovis/ts';
2
+ import { PaginationPosition } from '../Line';
2
3
 
3
4
  declare const _default: <T>(__VLS_props: Awaited<typeof __VLS_setup>["props"], __VLS_ctx?: __VLS_Prettify<Pick<Awaited<typeof __VLS_setup>, "attrs" | "emit" | "slots">>, __VLS_expose?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
4
5
  props: __VLS_Prettify<__VLS_OmitKeepDiscriminatedUnion<any & {
5
6
  data: T[];
7
+ stacked?: boolean;
6
8
  height: number;
7
9
  xLabel?: string;
8
10
  yLabel?: string;
9
11
  categories: Record<string, BulletLegendItemInterface>;
10
- xFormatter: (i: number, idx: number) => string;
12
+ xFormatter: (i: number, idx?: number) => string | number;
11
13
  yFormatter?: (i: number, idx?: number) => string | number;
12
14
  yNumTicks?: number;
13
15
  xNumTicks?: number;
14
- yAxis: string[];
16
+ yAxis: (keyof T)[];
15
17
  groupPadding?: number;
16
18
  barPadding?: number;
17
19
  radius?: number;
18
20
  hideLegend?: boolean;
21
+ orientation?: Orientation;
22
+ paginationPosition?: PaginationPosition;
19
23
  }, string | number | symbol>> & {} & any;
20
24
  expose(exposed: import('../../../vue/dist/vue.esm-bundler.js').ShallowUnwrapRef<{}>): void;
21
25
  attrs: any;
@@ -23,3 +27,6 @@ declare const _default: <T>(__VLS_props: Awaited<typeof __VLS_setup>["props"], _
23
27
  emit: typeof __VLS_emit;
24
28
  }>) => any;
25
29
  export default _default;
30
+ type __VLS_Prettify<T> = {
31
+ [K in keyof T]: T[K];
32
+ } & {};
@@ -865,7 +865,7 @@ function* selection_iterator() {
865
865
  }
866
866
  }
867
867
 
868
- var root$8 = [null];
868
+ var root$9 = [null];
869
869
 
870
870
  function Selection$1(groups, parents) {
871
871
  this._groups = groups;
@@ -873,7 +873,7 @@ function Selection$1(groups, parents) {
873
873
  }
874
874
 
875
875
  function selection() {
876
- return new Selection$1([[document.documentElement]], root$8);
876
+ return new Selection$1([[document.documentElement]], root$9);
877
877
  }
878
878
 
879
879
  function selection_selection() {
@@ -922,7 +922,7 @@ Selection$1.prototype = selection.prototype = {
922
922
  function select(selector) {
923
923
  return typeof selector === "string"
924
924
  ? new Selection$1([[document.querySelector(selector)]], [document.documentElement])
925
- : new Selection$1([[selector]], root$8);
925
+ : new Selection$1([[selector]], root$9);
926
926
  }
927
927
 
928
928
  function sourceEvent(event) {
@@ -9200,7 +9200,7 @@ const TooltipDefaultConfig = {
9200
9200
  className: undefined,
9201
9201
  };
9202
9202
 
9203
- const root$7 = css `
9203
+ const root$8 = css `
9204
9204
  label: tooltip;
9205
9205
  display: inline-block;
9206
9206
  left: 0;
@@ -9222,7 +9222,7 @@ const root$7 = css `
9222
9222
  /**
9223
9223
  * @deprecated This selector is deprecated and will be removed in future versions. Use `root` instead.
9224
9224
  */
9225
- const tooltip = root$7;
9225
+ const tooltip = root$8;
9226
9226
  const variables$2 = injectGlobal `
9227
9227
  :root {
9228
9228
  --vis-tooltip-background-color: rgba(255, 255, 255, 0.95);
@@ -9241,7 +9241,7 @@ const variables$2 = injectGlobal `
9241
9241
  --vis-dark-tooltip-shadow-color: rgba(0,0,0, 0.95);
9242
9242
  }
9243
9243
 
9244
- body.theme-dark ${`.${root$7}`} {
9244
+ body.theme-dark ${`.${root$8}`} {
9245
9245
  --vis-tooltip-background-color: var(--vis-dark-tooltip-background-color);
9246
9246
  --vis-tooltip-text-color: var(--vis-dark-tooltip-text-color);
9247
9247
  --vis-tooltip-border-color: var(--vis-dark-tooltip-border-color);
@@ -9271,12 +9271,12 @@ const nonInteractive = css `
9271
9271
  user-select: none;
9272
9272
  `;
9273
9273
 
9274
- const style$7 = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.defineProperty({
9274
+ const style$8 = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.defineProperty({
9275
9275
  __proto__: null,
9276
9276
  hidden,
9277
9277
  nonInteractive,
9278
9278
  positionFixed,
9279
- root: root$7,
9279
+ root: root$8,
9280
9280
  show,
9281
9281
  tooltip,
9282
9282
  variables: variables$2
@@ -9290,7 +9290,7 @@ class Tooltip {
9290
9290
  this._setContainerPositionThrottled = throttle(this._setContainerPosition, 500);
9291
9291
  this._isShown = false;
9292
9292
  this.element = document.createElement('div');
9293
- this.div = select(this.element).attr('class', root$7);
9293
+ this.div = select(this.element).attr('class', root$8);
9294
9294
  this.setConfig(config);
9295
9295
  this.components = this.config.components;
9296
9296
  // Set up MutationObserver to automatically re-position the tooltip
@@ -9605,7 +9605,7 @@ class Tooltip {
9605
9605
  (_a = this.div) === null || _a === void 0 ? void 0 : _a.remove();
9606
9606
  }
9607
9607
  }
9608
- Tooltip.selectors = style$7;
9608
+ Tooltip.selectors = style$8;
9609
9609
 
9610
9610
  function constant(x) {
9611
9611
  return function constant() {
@@ -10438,14 +10438,14 @@ const symbolTriangle = {
10438
10438
 
10439
10439
  const c$1 = -0.5;
10440
10440
  const s$1 = sqrt(3) / 2;
10441
- const k = 1 / sqrt(12);
10442
- const a = (k / 2 + 1) * 3;
10441
+ const k$1 = 1 / sqrt(12);
10442
+ const a = (k$1 / 2 + 1) * 3;
10443
10443
 
10444
10444
  const symbolWye = {
10445
10445
  draw(context, size) {
10446
10446
  const r = sqrt(size / a);
10447
- const x0 = r / 2, y0 = r * k;
10448
- const x1 = x0, y1 = r * k + r;
10447
+ const x0 = r / 2, y0 = r * k$1;
10448
+ const x1 = x0, y1 = r * k$1 + r;
10449
10449
  const x2 = -x1, y2 = y1;
10450
10450
  context.moveTo(x0, y0);
10451
10451
  context.lineTo(x1, y1);
@@ -12142,7 +12142,7 @@ const Curve = {
12142
12142
 
12143
12143
  const LineDefaultConfig = Object.assign(Object.assign({}, XYComponentDefaultConfig), { curveType: CurveType.MonotoneX, lineWidth: 2, lineDashArray: undefined, fallbackValue: undefined, highlightOnHover: false, cursor: null, interpolateMissingData: false });
12144
12144
 
12145
- const globalStyles$4 = injectGlobal `
12145
+ const globalStyles$5 = injectGlobal `
12146
12146
  :root {
12147
12147
  --vis-line-cursor: default;
12148
12148
  --vis-line-stroke-dasharray: none;
@@ -12153,7 +12153,7 @@ const globalStyles$4 = injectGlobal `
12153
12153
  --vis-line-gapfill-stroke-dashoffset: 0;
12154
12154
  }
12155
12155
  `;
12156
- const root$6 = css `
12156
+ const root$7 = css `
12157
12157
  label: line-component;
12158
12158
  `;
12159
12159
  const line$1 = css `
@@ -12184,15 +12184,15 @@ const interpolatedPath = css `
12184
12184
  stroke-opacity: var(--vis-line-gapfill-stroke-opacity);
12185
12185
  `;
12186
12186
 
12187
- const style$6 = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.defineProperty({
12187
+ const style$7 = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.defineProperty({
12188
12188
  __proto__: null,
12189
12189
  dim,
12190
- globalStyles: globalStyles$4,
12190
+ globalStyles: globalStyles$5,
12191
12191
  interpolatedPath,
12192
12192
  line: line$1,
12193
12193
  linePath,
12194
12194
  lineSelectionHelper,
12195
- root: root$6
12195
+ root: root$7
12196
12196
  }, Symbol.toStringTag, { value: 'Module' }));
12197
12197
 
12198
12198
  class Line extends XYComponentCore {
@@ -12369,7 +12369,7 @@ class Line extends XYComponentCore {
12369
12369
  }
12370
12370
  }
12371
12371
  }
12372
- Line.selectors = style$6;
12372
+ Line.selectors = style$7;
12373
12373
 
12374
12374
  /*
12375
12375
  * Generate SVG path for rectangle with rounded corners
@@ -12412,6 +12412,254 @@ function roundedRectPath({ x, y, w, h, tl = false, tr = false, bl = false, br =
12412
12412
  return path;
12413
12413
  }
12414
12414
 
12415
+ const StackedBarDefaultConfig = Object.assign(Object.assign({}, XYComponentDefaultConfig), { color: undefined, barMaxWidth: undefined, barWidth: undefined, dataStep: undefined, barPadding: 0.0, roundedCorners: 2, cursor: null, barMinHeight1Px: false, barMinHeightZeroValue: null, orientation: Orientation.Vertical });
12416
+
12417
+ const root$6 = css `
12418
+ label: stacked-bar-component;
12419
+ `;
12420
+ const globalStyles$4 = injectGlobal `
12421
+ :root {
12422
+ --vis-stacked-bar-cursor: default;
12423
+ --vis-stacked-bar-fill-color: var(--vis-color-main);
12424
+ --vis-stacked-bar-stroke-color: none;
12425
+ --vis-stacked-bar-stroke-width: 0px;
12426
+ --vis-stacked-bar-hover-stroke-width: none;
12427
+ --vis-stacked-bar-hover-stroke-color: none;
12428
+
12429
+ /* Dark Theme */
12430
+ --vis-dark-stacked-bar-stroke-color: none;
12431
+ }
12432
+
12433
+ body.theme-dark ${`.${root$6}`} {
12434
+ --vis-stacked-bar-stroke-color: var(--vis-dark-stacked-bar-stroke-color);
12435
+ }
12436
+ `;
12437
+ const bar$1 = css `
12438
+ label: bar;
12439
+ fill: var(--vis-stacked-bar-fill-color);
12440
+ stroke: var(--vis-stacked-bar-stroke-color);
12441
+ stroke-width: var(--vis-stacked-bar-stroke-width);
12442
+ cursor: var(--vis-stacked-bar-cursor);
12443
+
12444
+ &:hover {
12445
+ stroke-width: var(--vis-stacked-bar-hover-stroke-width);
12446
+ stroke: var(--vis-stacked-bar-hover-stroke-color);
12447
+ }
12448
+ `;
12449
+ const barGroup$1 = css `
12450
+ label: barGroup;
12451
+ `;
12452
+ const barGroupExit$1 = css `
12453
+ label: barGroupExit;
12454
+ `;
12455
+
12456
+ const style$6 = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.defineProperty({
12457
+ __proto__: null,
12458
+ bar: bar$1,
12459
+ barGroup: barGroup$1,
12460
+ barGroupExit: barGroupExit$1,
12461
+ globalStyles: globalStyles$4,
12462
+ root: root$6
12463
+ }, Symbol.toStringTag, { value: 'Module' }));
12464
+
12465
+ class StackedBar extends XYComponentCore {
12466
+ constructor(config) {
12467
+ super();
12468
+ this._defaultConfig = StackedBarDefaultConfig;
12469
+ this.config = this._defaultConfig;
12470
+ this.getAccessors = () => (isArray(this.config.y) ? this.config.y : [this.config.y]);
12471
+ this.stacked = true;
12472
+ this.events = {};
12473
+ this._barData = [];
12474
+ if (config)
12475
+ this.setConfig(config);
12476
+ }
12477
+ get bleed() {
12478
+ this._barData = this._getVisibleData();
12479
+ if (this._barData.length === 0)
12480
+ return { top: 0, bottom: 0, left: 0, right: 0 };
12481
+ // By default, horizontal orientation is "flipped", i.e. the `yDirection` of `XYContainer` is set to `Direction.North`
12482
+ const isHorizontalAndFlipped = !this.isVertical() && (this.dataScale.range()[0] > this.dataScale.range()[1]);
12483
+ const dataDomain = this.dataScale.domain();
12484
+ const halfGroupWidth = this._getBarWidth() / 2;
12485
+ const dataScaleValues = this._barData.map((d, i) => getNumber(d, this.config.x, i));
12486
+ const firstDataValue = min$1(dataScaleValues);
12487
+ const lastDataValue = max$1(dataScaleValues);
12488
+ const firstValuePx = this.dataScale(firstDataValue);
12489
+ const lastValuePx = this.dataScale(lastDataValue);
12490
+ const dataDomainRequiredStart = this.dataScale.invert(firstValuePx + (isHorizontalAndFlipped ? halfGroupWidth : -halfGroupWidth));
12491
+ const dataDomainRequiredEnd = this.dataScale.invert(lastValuePx + (isHorizontalAndFlipped ? -halfGroupWidth : halfGroupWidth));
12492
+ const bleedPxStart = dataDomainRequiredStart <= dataDomain[0] ? this.dataScale(dataDomain[0]) - this.dataScale(dataDomainRequiredStart) : 0;
12493
+ const bleedPxEnd = dataDomainRequiredEnd > dataDomain[1] ? this.dataScale(dataDomainRequiredEnd) - this.dataScale(dataDomain[1]) : 0;
12494
+ return {
12495
+ top: this.isVertical() ? 0 : (isHorizontalAndFlipped ? -bleedPxEnd : bleedPxStart),
12496
+ bottom: this.isVertical() ? 0 : (isHorizontalAndFlipped ? -bleedPxStart : bleedPxEnd),
12497
+ left: this.isVertical() ? bleedPxStart : 0,
12498
+ right: this.isVertical() ? bleedPxEnd : 0,
12499
+ };
12500
+ }
12501
+ get dataScale() {
12502
+ return this.isVertical() ? this.xScale : this.yScale;
12503
+ }
12504
+ get valueScale() {
12505
+ return this.isVertical() ? this.yScale : this.xScale;
12506
+ }
12507
+ isVertical() {
12508
+ return this.config.orientation === Orientation.Vertical;
12509
+ }
12510
+ _render(customDuration) {
12511
+ const { config } = this;
12512
+ const duration = isNumber(customDuration) ? customDuration : config.duration;
12513
+ const yAccessors = this.getAccessors();
12514
+ const stacked = getStackedData(this._barData, 0, yAccessors, this._prevNegative);
12515
+ this._prevNegative = stacked.map(s => !!s.isMostlyNegative);
12516
+ const barGroups = this.g
12517
+ .selectAll(`.${barGroup$1}`)
12518
+ .data(this._barData, (d, i) => { var _a; return `${(_a = getString(d, config.id, i)) !== null && _a !== void 0 ? _a : i}`; });
12519
+ const getBarGroupsTransform = (d, i) => {
12520
+ const v = this.dataScale(getNumber(d, config.x, i));
12521
+ const x = this.isVertical() ? v : 0;
12522
+ const y = this.isVertical() ? 0 : v;
12523
+ return `translate(${x},${y})`;
12524
+ };
12525
+ const barGroupsEnter = barGroups.enter().append('g')
12526
+ .attr('class', barGroup$1)
12527
+ .attr('transform', getBarGroupsTransform)
12528
+ .style('opacity', 1);
12529
+ const barGroupsMerged = barGroupsEnter.merge(barGroups);
12530
+ smartTransition(barGroupsMerged, duration)
12531
+ .attr('transform', getBarGroupsTransform)
12532
+ .style('opacity', 1);
12533
+ const barGroupExit$1$1 = barGroups.exit()
12534
+ .attr('class', barGroupExit$1);
12535
+ smartTransition(barGroupExit$1$1, duration)
12536
+ .style('opacity', 0)
12537
+ .remove();
12538
+ // Animate bars from exiting groups going down
12539
+ smartTransition(barGroupExit$1$1.selectAll(`.${bar$1}`), duration)
12540
+ .attr('transform', this.isVertical()
12541
+ ? `translate(0,${this._height / 3})`
12542
+ : `translate(${this._width / 6},0)`);
12543
+ // Render Bars
12544
+ const bars = barGroupsMerged
12545
+ .selectAll(`.${bar$1}`)
12546
+ .data((d, j) => stacked.map((s, stackIndex) => (Object.assign(Object.assign({}, d), { _index: j, _stacked: s[j],
12547
+ // Ending bar if the next stack is not the same as the current one
12548
+ _ending: (stackIndex === stacked.length - 1) ||
12549
+ ((stackIndex <= stacked.length - 1) && stacked[stackIndex + 1][j][0] !== s[j][1]) }))));
12550
+ const barsEnter = bars.enter().append('path')
12551
+ .attr('class', bar$1)
12552
+ .attr('d', (d, j) => this._getBarPath(d, j, true))
12553
+ .style('fill', (d, j) => getColor(d, config.color, j));
12554
+ const barsMerged = barsEnter.merge(bars);
12555
+ smartTransition(barsMerged, duration)
12556
+ .attr('d', (d, j) => this._getBarPath(d, j))
12557
+ .style('fill', (d, j) => getColor(d, config.color, j))
12558
+ .style('cursor', (d, j) => getString(d, config.cursor, j));
12559
+ smartTransition(bars.exit(), duration)
12560
+ .style('opacity', 0)
12561
+ .remove();
12562
+ }
12563
+ _getBarWidth() {
12564
+ const { config, datamodel: { data } } = this;
12565
+ if (isEmpty(data))
12566
+ return 0;
12567
+ if (config.barWidth)
12568
+ return min$1([config.barWidth, config.barMaxWidth]);
12569
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
12570
+ // @ts-ignore
12571
+ const isOrdinal = this.dataScale.bandwidth;
12572
+ const domain = (this.dataScale.domain ? this.dataScale.domain() : []);
12573
+ const domainLength = isOrdinal ? domain.length : domain[1] - domain[0];
12574
+ // If the dataStep property is provided the amount of data elements is calculates as domainLength / dataStep
12575
+ // otherwise we get the number of data elements within the domain range
12576
+ // Or if the scale is ordinal we use data.length
12577
+ let dataSize = (1 + domainLength / config.dataStep) ||
12578
+ (!isOrdinal && data.filter((d, i) => {
12579
+ const value = getNumber(d, config.x, i);
12580
+ return (value >= domain[0]) && (value <= domain[1]);
12581
+ }).length) ||
12582
+ data.length;
12583
+ // We increase the dataSize by 1 to take into account possible additional domain space
12584
+ if (!isOrdinal && dataSize >= 2)
12585
+ dataSize += 1;
12586
+ const c = dataSize < 2 ? 1 : 1 - config.barPadding;
12587
+ const barWidth = c * (this.isVertical() ? this._width : this._height) / dataSize;
12588
+ return min$1([barWidth, config.barMaxWidth]);
12589
+ }
12590
+ _getVisibleData() {
12591
+ const { config, datamodel: { data } } = this;
12592
+ const groupWidth = this._getBarWidth();
12593
+ const halfGroupWidthPx = data.length < 2 ? 0 : groupWidth / 2;
12594
+ const scale = this.dataScale;
12595
+ const halfGroupWidth = Math.abs(scale.invert(halfGroupWidthPx) - scale.invert(0));
12596
+ const filtered = data === null || data === void 0 ? void 0 : data.filter((d, i) => {
12597
+ const v = getNumber(d, config.x, i);
12598
+ const domain = scale.domain();
12599
+ const domainMin = +domain[0];
12600
+ const domainMax = +domain[1];
12601
+ return (v >= (domainMin - halfGroupWidth)) && (v <= (domainMax + halfGroupWidth));
12602
+ });
12603
+ return filtered;
12604
+ }
12605
+ _getBarPath(d, accessorIndex, isEntering = false) {
12606
+ const { config } = this;
12607
+ const yAccessors = this.getAccessors();
12608
+ const barWidth = this._getBarWidth();
12609
+ const isNegative = d._stacked[1] < 0;
12610
+ const isEnding = d._ending; // The most top bar or, if the value is negative, the most bottom bar
12611
+ const value = getNumber(d, yAccessors[accessorIndex], d._index);
12612
+ const height = isEntering ? 0 : Math.abs(this.valueScale(d._stacked[0]) - this.valueScale(d._stacked[1]));
12613
+ const h = !isEntering && config.barMinHeight1Px && (height < 1) && isFinite(value) && (value !== config.barMinHeightZeroValue) ? 1 : height;
12614
+ const y = isEntering
12615
+ ? this.valueScale(0)
12616
+ : this.valueScale(isNegative ? d._stacked[0] : d._stacked[1]) - (height < 1 && config.barMinHeight1Px ? 1 : 0);
12617
+ const x = -barWidth / 2;
12618
+ const width = barWidth;
12619
+ const cornerRadius = config.roundedCorners
12620
+ ? isNumber(config.roundedCorners) ? +config.roundedCorners : width / 2
12621
+ : 0;
12622
+ const cornerRadiusClamped = clamp(cornerRadius, 0, Math.min(height, width) / 2);
12623
+ const isNorthDirected = this.yScale.range()[0] > this.yScale.range()[1];
12624
+ return roundedRectPath({
12625
+ x: this.isVertical() ? x : y - h,
12626
+ y: this.isVertical() ? y + (isNorthDirected ? 0 : -h) : x,
12627
+ w: this.isVertical() ? width : h,
12628
+ h: this.isVertical() ? h : width,
12629
+ tl: isEnding && (this.isVertical()
12630
+ ? (!isNegative && isNorthDirected) || (isNegative && !isNorthDirected)
12631
+ : isNegative),
12632
+ tr: isEnding && (this.isVertical()
12633
+ ? (!isNegative && isNorthDirected) || (isNegative && !isNorthDirected)
12634
+ : !isNegative),
12635
+ br: isEnding && (this.isVertical()
12636
+ ? (isNegative && isNorthDirected) || (!isNegative && !isNorthDirected)
12637
+ : !isNegative),
12638
+ bl: isEnding && (this.isVertical()
12639
+ ? (isNegative && isNorthDirected) || (!isNegative && !isNorthDirected)
12640
+ : isNegative),
12641
+ r: cornerRadiusClamped,
12642
+ });
12643
+ }
12644
+ getValueScaleExtent(scaleByVisibleData) {
12645
+ const { datamodel } = this;
12646
+ const yAccessors = this.getAccessors();
12647
+ const data = scaleByVisibleData ? this._getVisibleData() : datamodel.data;
12648
+ return getStackedExtent(data, ...yAccessors);
12649
+ }
12650
+ getDataScaleExtent() {
12651
+ const { config, datamodel } = this;
12652
+ return getExtent(datamodel.data, config.x);
12653
+ }
12654
+ getYDataExtent(scaleByVisibleData) {
12655
+ return this.isVertical() ? this.getValueScaleExtent(scaleByVisibleData) : this.getDataScaleExtent();
12656
+ }
12657
+ getXDataExtent() {
12658
+ return this.isVertical() ? this.getDataScaleExtent() : this.getValueScaleExtent(false);
12659
+ }
12660
+ }
12661
+ StackedBar.selectors = style$6;
12662
+
12415
12663
  const GroupedBarDefaultConfig = Object.assign(Object.assign({}, XYComponentDefaultConfig), { color: undefined, groupMaxWidth: undefined, groupWidth: undefined, dataStep: undefined, groupPadding: 0.05, barPadding: 0.0, roundedCorners: 2, barMinHeight: 2, cursor: null, orientation: Orientation.Vertical });
12416
12664
 
12417
12665
  const root$5 = css `
@@ -15311,6 +15559,52 @@ const b = { "data-vis-component": "" }, S$1 = /* @__PURE__ */ defineComponent({
15311
15559
  }
15312
15560
  });
15313
15561
 
15562
+ const k = { "data-vis-component": "" }, w = /* @__PURE__ */ defineComponent({
15563
+ __name: "index",
15564
+ props: {
15565
+ color: {},
15566
+ barWidth: {},
15567
+ barMaxWidth: {},
15568
+ dataStep: {},
15569
+ barPadding: {},
15570
+ roundedCorners: { type: [Number, Boolean] },
15571
+ cursor: {},
15572
+ barMinHeight1Px: { type: Boolean },
15573
+ barMinHeightZeroValue: {},
15574
+ orientation: {},
15575
+ x: {},
15576
+ y: {},
15577
+ id: { type: Function },
15578
+ xScale: { type: [Object, Function] },
15579
+ yScale: { type: [Object, Function] },
15580
+ excludeFromDomainCalculation: { type: Boolean },
15581
+ duration: {},
15582
+ events: {},
15583
+ attributes: {},
15584
+ data: {}
15585
+ },
15586
+ setup(d, { expose: l }) {
15587
+ const o$1 = inject(o), r = d, a = computed(() => o$1.data.value ?? r.data), n = m(r), t = ref();
15588
+ return onMounted(() => {
15589
+ nextTick(() => {
15590
+ var e;
15591
+ t.value = new StackedBar(n.value), (e = t.value) == null || e.setData(a.value), o$1.update(t.value);
15592
+ });
15593
+ }), onUnmounted(() => {
15594
+ var e;
15595
+ (e = t.value) == null || e.destroy(), o$1.destroy();
15596
+ }), watch(n, (e, c) => {
15597
+ var s;
15598
+ f(e, c) || (s = t.value) == null || s.setConfig(n.value);
15599
+ }), watch(a, () => {
15600
+ var e;
15601
+ (e = t.value) == null || e.setData(a.value);
15602
+ }), l({
15603
+ component: t
15604
+ }), (e, c) => (openBlock(), createElementBlock("div", k));
15605
+ }
15606
+ });
15607
+
15314
15608
  const x = { "data-vis-component": "" }, E = /* @__PURE__ */ defineComponent({
15315
15609
  __name: "index",
15316
15610
  props: {
@@ -15433,7 +15727,7 @@ const S = /* @__PURE__ */ defineComponent({
15433
15727
 
15434
15728
  (function(){try{if(typeof document<"u"){var e=document.createElement("style");e.appendChild(document.createTextNode(".unovis-xy-container,.unovis-single-container{display:block;position:relative;width:100%}[data-vis-leaflet-map],[data-vis-leaflet-flow-map]{display:block;position:relative}[data-vis-bullet-legend]{display:block}")),document.head.appendChild(e);}}catch(t){console.error("vite-plugin-css-injected-by-js",t);}})();
15435
15729
 
15436
- const _hoisted_1$4 = {
15730
+ const _hoisted_1$3 = {
15437
15731
  key: 0,
15438
15732
  class: "flex items center justify-end"
15439
15733
  };
@@ -15547,7 +15841,7 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
15547
15841
  ]),
15548
15842
  _: 1
15549
15843
  }, 8, ["data", "height", "svg-defs"]),
15550
- !_ctx.hideLegend ? (openBlock(), createElementBlock("div", _hoisted_1$4, [
15844
+ !_ctx.hideLegend ? (openBlock(), createElementBlock("div", _hoisted_1$3, [
15551
15845
  createVNode(unref(S), {
15552
15846
  items: Object.values(_ctx.categories)
15553
15847
  }, null, 8, ["items"])
@@ -15557,8 +15851,8 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
15557
15851
  }
15558
15852
  });
15559
15853
 
15560
- const _hoisted_1$3 = { class: "flex flex-col space-y-4" };
15561
- const _hoisted_2$2 = { class: "flex items center justify-end" };
15854
+ const _hoisted_1$2 = { class: "flex flex-col space-y-4" };
15855
+ const _hoisted_2$1 = { class: "flex items center justify-end" };
15562
15856
  const _sfc_main$3 = /* @__PURE__ */ defineComponent({
15563
15857
  __name: "AreaStackedChart",
15564
15858
  props: {
@@ -15568,14 +15862,14 @@ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
15568
15862
  setup(__props) {
15569
15863
  const props = __props;
15570
15864
  const x = (d) => {
15571
- return Number.parseInt(d.date);
15865
+ return Number.parseInt(d.time);
15572
15866
  };
15573
15867
  const y = [
15574
15868
  (d) => d.firstTime,
15575
15869
  (d) => d.returning
15576
15870
  ];
15577
15871
  return (_ctx, _cache) => {
15578
- return openBlock(), createElementBlock("div", _hoisted_1$3, [
15872
+ return openBlock(), createElementBlock("div", _hoisted_1$2, [
15579
15873
  createVNode(unref($), {
15580
15874
  data: _ctx.data,
15581
15875
  height: 200
@@ -15600,7 +15894,7 @@ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
15600
15894
  ]),
15601
15895
  _: 1
15602
15896
  }, 8, ["data"]),
15603
- createElementVNode("div", _hoisted_2$2, [
15897
+ createElementVNode("div", _hoisted_2$1, [
15604
15898
  createVNode(unref(S), {
15605
15899
  items: Object.values(_ctx.categories)
15606
15900
  }, null, 8, ["items"])
@@ -15610,13 +15904,9 @@ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
15610
15904
  }
15611
15905
  });
15612
15906
 
15613
- const _hoisted_1$2 = { class: "space-y-2" };
15614
- const _hoisted_2$1 = {
15615
- key: 0,
15616
- class: "flex items center justify-end"
15617
- };
15907
+ const _hoisted_1$1 = { class: "flex items center justify-end" };
15618
15908
  const _sfc_main$2 = /* @__PURE__ */ defineComponent({
15619
- __name: "BarChart",
15909
+ __name: "LineChart",
15620
15910
  props: {
15621
15911
  data: {},
15622
15912
  height: {},
@@ -15625,18 +15915,115 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
15625
15915
  categories: {},
15626
15916
  xFormatter: { type: Function },
15627
15917
  yFormatter: { type: Function },
15918
+ curveType: {},
15919
+ yNumTicks: {},
15920
+ xNumTicks: {},
15921
+ paginationPoisition: {}
15922
+ },
15923
+ setup(__props) {
15924
+ const props = __props;
15925
+ const color = (key) => Object.values(props.categories)[key].color;
15926
+ const generateTooltip = computed(() => (d) => {
15927
+ const app = createApp(_sfc_main$5, {
15928
+ data: d,
15929
+ categories: props.categories
15930
+ });
15931
+ const container = document.createElement("div");
15932
+ app.mount(container);
15933
+ const html = container.innerHTML;
15934
+ app.unmount();
15935
+ return html;
15936
+ });
15937
+ return (_ctx, _cache) => {
15938
+ return openBlock(), createElementBlock("div", {
15939
+ class: normalizeClass(["space-y-4 flex flex-col", {
15940
+ "flex-col-reverse": props.paginationPoisition === "top"
15941
+ }])
15942
+ }, [
15943
+ createVNode(unref($), {
15944
+ data: _ctx.data,
15945
+ height: _ctx.height
15946
+ }, {
15947
+ default: withCtx(() => [
15948
+ createVNode(unref(z), {
15949
+ "horizontal-placement": unref(Position).Right,
15950
+ "vertical-placement": unref(Position).Top
15951
+ }, null, 8, ["horizontal-placement", "vertical-placement"]),
15952
+ (openBlock(true), createElementBlock(Fragment, null, renderList(Object.keys(props.categories), (i, iKey) => {
15953
+ return openBlock(), createBlock(unref(S$1), {
15954
+ key: iKey,
15955
+ x: (_, i2) => i2,
15956
+ y: (d) => d[i],
15957
+ color: color(iKey),
15958
+ "curve-type": _ctx.curveType ?? unref(CurveType).MonotoneX
15959
+ }, null, 8, ["x", "y", "color", "curve-type"]);
15960
+ }), 128)),
15961
+ createVNode(unref(O), {
15962
+ type: "x",
15963
+ "tick-format": _ctx.xFormatter,
15964
+ "num-ticks": _ctx.xNumTicks ?? 4,
15965
+ label: _ctx.xLabel,
15966
+ "label-margin": 8,
15967
+ "domain-line": false,
15968
+ "grid-line": false
15969
+ }, null, 8, ["tick-format", "num-ticks", "label"]),
15970
+ createVNode(unref(O), {
15971
+ type: "y",
15972
+ "num-ticks": _ctx.yNumTicks ?? 4,
15973
+ "tick-format": _ctx.yFormatter,
15974
+ label: _ctx.yLabel,
15975
+ "domain-line": false
15976
+ }, null, 8, ["num-ticks", "tick-format", "label"]),
15977
+ createVNode(unref(A), {
15978
+ color: "#666",
15979
+ template: generateTooltip.value
15980
+ }, null, 8, ["template"])
15981
+ ]),
15982
+ _: 1
15983
+ }, 8, ["data", "height"]),
15984
+ createElementVNode("div", _hoisted_1$1, [
15985
+ createVNode(unref(S), {
15986
+ items: Object.values(_ctx.categories)
15987
+ }, null, 8, ["items"])
15988
+ ])
15989
+ ], 2);
15990
+ };
15991
+ }
15992
+ });
15993
+
15994
+ var PaginationPosition = /* @__PURE__ */ ((PaginationPosition2) => {
15995
+ PaginationPosition2["Top"] = "top";
15996
+ PaginationPosition2["Bottom"] = "bottom";
15997
+ return PaginationPosition2;
15998
+ })(PaginationPosition || {});
15999
+
16000
+ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
16001
+ __name: "BarChart",
16002
+ props: {
16003
+ data: {},
16004
+ stacked: { type: Boolean },
16005
+ height: {},
16006
+ xLabel: {},
16007
+ yLabel: {},
16008
+ categories: {},
16009
+ xFormatter: {},
16010
+ yFormatter: {},
15628
16011
  yNumTicks: {},
15629
16012
  xNumTicks: {},
15630
16013
  yAxis: {},
15631
16014
  groupPadding: {},
15632
16015
  barPadding: {},
15633
16016
  radius: {},
15634
- hideLegend: { type: Boolean }
16017
+ hideLegend: { type: Boolean },
16018
+ orientation: { default: Orientation.Vertical },
16019
+ paginationPosition: { default: PaginationPosition.Bottom }
15635
16020
  },
15636
16021
  setup(__props) {
15637
16022
  const props = __props;
15638
- const yAxis = props.yAxis.map((key) => (d) => {
15639
- return d[key];
16023
+ const yAxis = computed(() => {
16024
+ return props.yAxis.map((key) => (d) => {
16025
+ return d[key];
16026
+ });
15640
16027
  });
15641
16028
  const color = (_, i) => Object.values(props.categories)[i].color;
15642
16029
  const generateTooltip = computed(() => (d) => {
@@ -15650,8 +16037,11 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
15650
16037
  app.unmount();
15651
16038
  return html;
15652
16039
  });
16040
+ const PaginationPositionTop = computed(() => props.paginationPosition === PaginationPosition.Top);
15653
16041
  return (_ctx, _cache) => {
15654
- return openBlock(), createElementBlock("div", _hoisted_1$2, [
16042
+ return openBlock(), createElementBlock("div", {
16043
+ class: normalizeClass(["flex flex-col space-y-4", { "flex-col-reverse": PaginationPositionTop.value }])
16044
+ }, [
15655
16045
  createVNode(unref($), { height: _ctx.height }, {
15656
16046
  default: withCtx(() => [
15657
16047
  createVNode(unref(z), {
@@ -15659,51 +16049,69 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
15659
16049
  [unref(GroupedBar).selectors.bar]: generateTooltip.value
15660
16050
  }
15661
16051
  }, null, 8, ["triggers"]),
15662
- createVNode(unref(D), {
16052
+ !_ctx.stacked ? (openBlock(), createBlock(unref(D), {
16053
+ key: 0,
16054
+ data: _ctx.data,
16055
+ x: (_, i) => i,
16056
+ y: yAxis.value,
16057
+ "grid-line": false,
16058
+ "domain-line": false,
16059
+ color,
16060
+ "rounded-corners": _ctx.radius ?? 0,
16061
+ "group-padding": _ctx.groupPadding ?? 0,
16062
+ "bar-padding": _ctx.barPadding ?? 0.2,
16063
+ orientation: _ctx.orientation ?? unref(Orientation).Vertical
16064
+ }, null, 8, ["data", "x", "y", "rounded-corners", "group-padding", "bar-padding", "orientation"])) : (openBlock(), createBlock(unref(w), {
16065
+ key: 1,
15663
16066
  data: _ctx.data,
15664
16067
  x: (_, i) => i,
15665
- y: unref(yAxis),
16068
+ y: yAxis.value,
15666
16069
  "grid-line": false,
15667
16070
  "domain-line": false,
15668
16071
  color,
15669
16072
  "rounded-corners": _ctx.radius ?? 0,
15670
16073
  "group-padding": _ctx.groupPadding ?? 0,
15671
- "bar-padding": _ctx.barPadding ?? 0
15672
- }, null, 8, ["data", "x", "y", "rounded-corners", "group-padding", "bar-padding"]),
16074
+ "bar-padding": _ctx.barPadding ?? 0.2,
16075
+ orientation: _ctx.orientation ?? unref(Orientation).Vertical
16076
+ }, null, 8, ["data", "x", "y", "rounded-corners", "group-padding", "bar-padding", "orientation"])),
15673
16077
  createVNode(unref(O), {
15674
16078
  type: "x",
15675
16079
  label: _ctx.xLabel,
15676
16080
  "grid-line": false,
15677
16081
  "domain-line": false,
15678
16082
  "tick-format": _ctx.xFormatter,
15679
- "num-ticks": _ctx.xNumTicks
16083
+ "num-ticks": _ctx.xNumTicks,
16084
+ "tick-line": false
15680
16085
  }, null, 8, ["label", "tick-format", "num-ticks"]),
15681
16086
  createVNode(unref(O), {
15682
16087
  type: "y",
15683
16088
  label: _ctx.yLabel,
15684
- "grid-line": true,
16089
+ "grid-line": _ctx.orientation !== unref(Orientation).Horizontal,
15685
16090
  "domain-line": false,
15686
16091
  "tick-format": _ctx.yFormatter
15687
- }, null, 8, ["label", "tick-format"])
16092
+ }, null, 8, ["label", "grid-line", "tick-format"])
15688
16093
  ]),
15689
16094
  _: 1
15690
16095
  }, 8, ["height"]),
15691
- !_ctx.hideLegend ? (openBlock(), createElementBlock("div", _hoisted_2$1, [
16096
+ !_ctx.hideLegend ? (openBlock(), createElementBlock("div", {
16097
+ key: 0,
16098
+ class: normalizeClass(["flex items center justify-end", { "pb-4": PaginationPositionTop.value }])
16099
+ }, [
15692
16100
  createVNode(unref(S), {
15693
16101
  items: Object.values(_ctx.categories)
15694
16102
  }, null, 8, ["items"])
15695
- ])) : createCommentVNode("", true)
15696
- ]);
16103
+ ], 2)) : createCommentVNode("", true)
16104
+ ], 2);
15697
16105
  };
15698
16106
  }
15699
16107
  });
15700
16108
 
15701
- const _hoisted_1$1 = { class: "flex items-center justify-center" };
16109
+ const _hoisted_1 = { class: "flex items-center justify-center" };
15702
16110
  const _hoisted_2 = {
15703
16111
  key: 0,
15704
16112
  class: "flex items-center justify-center mt-4"
15705
16113
  };
15706
- const _sfc_main$1 = /* @__PURE__ */ defineComponent({
16114
+ const _sfc_main = /* @__PURE__ */ defineComponent({
15707
16115
  __name: "DonutChart",
15708
16116
  props: {
15709
16117
  type: {},
@@ -15729,7 +16137,7 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
15729
16137
  };
15730
16138
  return (_ctx, _cache) => {
15731
16139
  return openBlock(), createElementBlock(Fragment, null, [
15732
- createElementVNode("div", _hoisted_1$1, [
16140
+ createElementVNode("div", _hoisted_1, [
15733
16141
  createVNode(unref(b$2), {
15734
16142
  class: normalizeClass(isHalf ? "mt-24" : ""),
15735
16143
  data: _ctx.data,
@@ -15761,97 +16169,4 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
15761
16169
  }
15762
16170
  });
15763
16171
 
15764
- const _hoisted_1 = { class: "flex items center justify-end" };
15765
- const _sfc_main = /* @__PURE__ */ defineComponent({
15766
- __name: "LineChart",
15767
- props: {
15768
- data: {},
15769
- height: {},
15770
- xLabel: {},
15771
- yLabel: {},
15772
- categories: {},
15773
- xFormatter: { type: Function },
15774
- yFormatter: { type: Function },
15775
- curveType: {},
15776
- yNumTicks: {},
15777
- xNumTicks: {},
15778
- paginationPoisition: {}
15779
- },
15780
- setup(__props) {
15781
- const props = __props;
15782
- const color = (key) => Object.values(props.categories)[key].color;
15783
- const generateTooltip = computed(() => (d) => {
15784
- const app = createApp(_sfc_main$5, {
15785
- data: d,
15786
- categories: props.categories
15787
- });
15788
- const container = document.createElement("div");
15789
- app.mount(container);
15790
- const html = container.innerHTML;
15791
- app.unmount();
15792
- return html;
15793
- });
15794
- return (_ctx, _cache) => {
15795
- return openBlock(), createElementBlock("div", {
15796
- class: normalizeClass(["space-y-4 flex flex-col", {
15797
- "flex-col-reverse": props.paginationPoisition === "top"
15798
- }])
15799
- }, [
15800
- createVNode(unref($), {
15801
- data: _ctx.data,
15802
- height: _ctx.height
15803
- }, {
15804
- default: withCtx(() => [
15805
- createVNode(unref(z), {
15806
- "horizontal-placement": unref(Position).Right,
15807
- "vertical-placement": unref(Position).Top
15808
- }, null, 8, ["horizontal-placement", "vertical-placement"]),
15809
- (openBlock(true), createElementBlock(Fragment, null, renderList(Object.keys(props.categories), (i, iKey) => {
15810
- return openBlock(), createBlock(unref(S$1), {
15811
- key: iKey,
15812
- x: (_, i2) => i2,
15813
- y: (d) => d[i],
15814
- color: color(iKey),
15815
- "curve-type": _ctx.curveType ?? unref(CurveType).MonotoneX
15816
- }, null, 8, ["x", "y", "color", "curve-type"]);
15817
- }), 128)),
15818
- createVNode(unref(O), {
15819
- type: "x",
15820
- "tick-format": _ctx.xFormatter,
15821
- "num-ticks": _ctx.xNumTicks ?? 4,
15822
- label: _ctx.xLabel,
15823
- "label-margin": 8,
15824
- "domain-line": false,
15825
- "grid-line": false
15826
- }, null, 8, ["tick-format", "num-ticks", "label"]),
15827
- createVNode(unref(O), {
15828
- type: "y",
15829
- "num-ticks": _ctx.yNumTicks ?? 4,
15830
- "tick-format": _ctx.yFormatter,
15831
- label: _ctx.yLabel,
15832
- "domain-line": false
15833
- }, null, 8, ["num-ticks", "tick-format", "label"]),
15834
- createVNode(unref(A), {
15835
- color: "#666",
15836
- template: generateTooltip.value
15837
- }, null, 8, ["template"])
15838
- ]),
15839
- _: 1
15840
- }, 8, ["data", "height"]),
15841
- createElementVNode("div", _hoisted_1, [
15842
- createVNode(unref(S), {
15843
- items: Object.values(_ctx.categories)
15844
- }, null, 8, ["items"])
15845
- ])
15846
- ], 2);
15847
- };
15848
- }
15849
- });
15850
-
15851
- var PaginationPosition = /* @__PURE__ */ ((PaginationPosition2) => {
15852
- PaginationPosition2["Top"] = "top";
15853
- PaginationPosition2["Bottom"] = "bottom";
15854
- return PaginationPosition2;
15855
- })(PaginationPosition || {});
15856
-
15857
- export { _sfc_main$4 as AreaChart, _sfc_main$3 as AreaStackedChart, _sfc_main$2 as BarChart, _sfc_main$1 as DonutChart, _sfc_main as LineChart, PaginationPosition };
16172
+ export { _sfc_main$4 as AreaChart, _sfc_main$3 as AreaStackedChart, _sfc_main$1 as BarChart, _sfc_main as DonutChart, _sfc_main$2 as LineChart, PaginationPosition };
package/dist/index.d.ts CHANGED
@@ -4,5 +4,5 @@ import { default as Status } from './Status/Status.vue';
4
4
  import { default as Tooltip } from './Tooltip/Tooltip.vue';
5
5
 
6
6
  export { Progress, Status, Tooltip };
7
- export declare const loadCharts: () => Promise<ChartModule | {}>;
7
+ export declare const loadCharts: () => Promise<ChartModule>;
8
8
  export type LoadCharts = typeof loadCharts;
package/dist/index.js CHANGED
@@ -183,7 +183,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
183
183
 
184
184
  const loadCharts = () => {
185
185
  if (import.meta.client || typeof window !== "undefined") {
186
- return import('./charts-bM3o2NNr.js').then((module) => {
186
+ return import('./charts-CO6Yq10P.js').then((module) => {
187
187
  return module;
188
188
  });
189
189
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "vue-chrts",
3
3
  "type": "module",
4
- "version": "0.0.106",
4
+ "version": "0.0.107",
5
5
  "license": "MIT",
6
6
  "files": [
7
7
  "dist"