@carbon/charts-vue 0.43.0 → 0.45.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/CHANGELOG.md CHANGED
@@ -3,6 +3,38 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [0.45.1](https://github.com/carbon-design-system/carbon-charts/compare/v0.45.0...v0.45.1) (2021-08-23)
7
+
8
+ **Note:** Version bump only for package @carbon/charts-vue
9
+
10
+
11
+
12
+
13
+
14
+ # [0.45.0](https://github.com/carbon-design-system/carbon-charts/compare/v0.44.1...v0.45.0) (2021-08-19)
15
+
16
+ **Note:** Version bump only for package @carbon/charts-vue
17
+
18
+
19
+
20
+
21
+
22
+ ## [0.44.1](https://github.com/carbon-design-system/carbon-charts/compare/v0.44.0...v0.44.1) (2021-08-19)
23
+
24
+ **Note:** Version bump only for package @carbon/charts-vue
25
+
26
+
27
+
28
+
29
+
30
+ # [0.44.0](https://github.com/carbon-design-system/carbon-charts/compare/v0.43.0...v0.44.0) (2021-08-18)
31
+
32
+ **Note:** Version bump only for package @carbon/charts-vue
33
+
34
+
35
+
36
+
37
+
6
38
  # [0.43.0](https://github.com/carbon-design-system/carbon-charts/compare/v0.42.1...v0.43.0) (2021-08-17)
7
39
 
8
40
  **Note:** Version bump only for package @carbon/charts-vue
package/README.md CHANGED
@@ -11,21 +11,21 @@
11
11
  Run the following command using [npm](https://www.npmjs.com/):
12
12
 
13
13
  ```bash
14
- npm install -S @carbon/charts @carbon/charts-vue d3@5.x
14
+ npm install -S @carbon/charts @carbon/charts-vue d3
15
15
  ```
16
16
 
17
17
  If you prefer [Yarn](https://yarnpkg.com/en/), use the following command
18
18
  instead:
19
19
 
20
20
  ```bash
21
- yarn add @carbon/charts @carbon/charts-vue d3@5.x
21
+ yarn add @carbon/charts @carbon/charts-vue d3
22
22
  ```
23
23
 
24
24
  **Note:** you'd also need to install `carbon-components` if you're not using a bundled version of the library.
25
25
 
26
26
  ## Step-by-step instructions
27
27
 
28
- Read [here](https://carbon-design-system.github.io/carbon-charts/?path=/story/tutorials-getting-started--vue)
28
+ Read [here](https://carbon-design-system.github.io/carbon-charts/?path=/story/docs-getting-started--vue)
29
29
 
30
30
  ## Codesandbox examples
31
31
 
@@ -39,7 +39,7 @@ Although we will definitely introduce new models in the future as we start shipp
39
39
 
40
40
  For instance in the case of a donut chart you're able to pass in an additional field called `center` in your options configuring the donut center.
41
41
 
42
- For instructions on using the **tabular data format**, see [here](https://carbon-design-system.github.io/carbon-charts/?path=/story/tutorials--tabular-data-format)
42
+ For instructions on using the **tabular data format**, see [here](https://carbon-design-system.github.io/carbon-charts/?path=/story/docs-tutorials--tabular-data-format)
43
43
 
44
44
  There are also additional options available depending on the chart type being used, [see our demo examples here](https://github.com/carbon-design-system/carbon-charts/tree/master/packages/core/demo/data).
45
45
 
@@ -8033,11 +8033,12 @@ var tools_Tools;
8033
8033
  * @export
8034
8034
  * @param {any} item
8035
8035
  * @param {any} fullData
8036
+ * @param {string} key
8036
8037
  * @returns The percentage in the form of a number (1 significant digit if necessary)
8037
8038
  */
8038
- function convertValueToPercentage(item, fullData) {
8039
- var percentage = (item / fullData.reduce(function (accum, val) { return accum + val.value; }, 0)) *
8040
- 100;
8039
+ function convertValueToPercentage(item, fullData, key) {
8040
+ if (key === void 0) { key = 'value'; }
8041
+ var percentage = (item / fullData.reduce(function (accum, val) { return accum + val[key]; }, 0)) * 100;
8041
8042
  // if the value has any significant figures, keep 1
8042
8043
  return percentage % 1 !== 0
8043
8044
  ? parseFloat(percentage.toFixed(1))
@@ -8580,6 +8581,7 @@ var pieChart = tools_Tools.merge({}, chart, {
8580
8581
  },
8581
8582
  alignment: Alignments.LEFT,
8582
8583
  sortFunction: null,
8584
+ valueMapsTo: 'value',
8583
8585
  },
8584
8586
  });
8585
8587
  /**
@@ -8940,6 +8942,22 @@ function stackSeries(key) {
8940
8942
  return stack;
8941
8943
  });
8942
8944
 
8945
+ // CONCATENATED MODULE: /home/runner/work/carbon-charts/carbon-charts/node_modules/d3-shape/src/offset/diverging.js
8946
+ /* harmony default export */ var diverging = (function(series, order) {
8947
+ if (!((n = series.length) > 0)) return;
8948
+ for (var i, j = 0, d, dy, yp, yn, n, m = series[order[0]].length; j < m; ++j) {
8949
+ for (yp = yn = 0, i = 0; i < n; ++i) {
8950
+ if ((dy = (d = series[order[i]][j])[1] - d[0]) > 0) {
8951
+ d[0] = yp, d[1] = yp += dy;
8952
+ } else if (dy < 0) {
8953
+ d[1] = yn, d[0] = yn += dy;
8954
+ } else {
8955
+ d[0] = 0, d[1] = dy;
8956
+ }
8957
+ }
8958
+ }
8959
+ });
8960
+
8943
8961
  // CONCATENATED MODULE: /home/runner/work/carbon-charts/carbon-charts/node_modules/d3-array/src/array.js
8944
8962
  var array_array = Array.prototype;
8945
8963
 
@@ -9598,7 +9616,7 @@ var model_ChartModel = /** @class */ (function () {
9598
9616
  });
9599
9617
  };
9600
9618
  ChartModel.prototype.getStackedData = function (_a) {
9601
- var _b = _a.percentage, percentage = _b === void 0 ? false : _b, _c = _a.groups, groups = _c === void 0 ? null : _c;
9619
+ var _b = _a.percentage, percentage = _b === void 0 ? false : _b, _c = _a.groups, groups = _c === void 0 ? null : _c, _d = _a.divergent, divergent = _d === void 0 ? false : _d;
9602
9620
  var options = this.getOptions();
9603
9621
  var groupMapsTo = options.data.groupMapsTo;
9604
9622
  var dataGroupNames = this.getDataGroupNames(groups);
@@ -9624,7 +9642,10 @@ var model_ChartModel = /** @class */ (function () {
9624
9642
  });
9625
9643
  });
9626
9644
  }
9627
- return src_stack()
9645
+ var stackToUse = divergent
9646
+ ? src_stack().offset(diverging)
9647
+ : src_stack();
9648
+ return stackToUse
9628
9649
  .keys(dataGroupNames)(dataValuesGroupedByKeys)
9629
9650
  .map(function (series, i) {
9630
9651
  // Add data group names to each series
@@ -15907,26 +15928,6 @@ function max_max(values, valueof) {
15907
15928
  return max;
15908
15929
  }
15909
15930
 
15910
- // CONCATENATED MODULE: /home/runner/work/carbon-charts/carbon-charts/node_modules/d3-array/src/sum.js
15911
- function sum_sum(values, valueof) {
15912
- let sum = 0;
15913
- if (valueof === undefined) {
15914
- for (let value of values) {
15915
- if (value = +value) {
15916
- sum += value;
15917
- }
15918
- }
15919
- } else {
15920
- let index = -1;
15921
- for (let value of values) {
15922
- if (value = +valueof(value, ++index, values)) {
15923
- sum += value;
15924
- }
15925
- }
15926
- }
15927
- return sum;
15928
- }
15929
-
15930
15931
  // CONCATENATED MODULE: /home/runner/work/carbon-charts/carbon-charts/node_modules/date-fns/esm/toDate/index.js
15931
15932
  /**
15932
15933
  * @name toDate
@@ -17478,11 +17479,21 @@ var scales_cartesian_CartesianScales = /** @class */ (function (_super) {
17478
17479
  groups: dataGroupNames,
17479
17480
  });
17480
17481
  var nonStackedGroupsData = displayData.filter(function (datum) { return !dataGroupNames.includes(datum[groupMapsTo_1]); });
17481
- var stackedValues = dataValuesGroupedByKeys.map(function (dataValues) {
17482
+ var stackedValues_1 = [];
17483
+ dataValuesGroupedByKeys.forEach(function (dataValues) {
17482
17484
  var sharedStackKey = dataValues.sharedStackKey, numericalValues = __rest(dataValues, ["sharedStackKey"]);
17483
- return sum_sum(Object.values(numericalValues));
17485
+ var positiveSum = 0, negativeSum = 0;
17486
+ Object.values(numericalValues).forEach(function (value) {
17487
+ if (value < 0) {
17488
+ negativeSum += value;
17489
+ }
17490
+ else {
17491
+ positiveSum += value;
17492
+ }
17493
+ });
17494
+ stackedValues_1.push([negativeSum, positiveSum]);
17484
17495
  });
17485
- allDataValues = scales_cartesian_spreadArrays(stackedValues, nonStackedGroupsData.map(function (datum) { return datum[mapsTo]; }));
17496
+ allDataValues = scales_cartesian_spreadArrays(tools_Tools.flatten(stackedValues_1), nonStackedGroupsData.map(function (datum) { return datum[mapsTo]; }));
17486
17497
  }
17487
17498
  else {
17488
17499
  allDataValues = [];
@@ -26460,7 +26471,9 @@ var bar_stacked_StackedBar = /** @class */ (function (_super) {
26460
26471
  // Create the data and keys that'll be used by the stack layout
26461
26472
  var stackData = this.model.getStackedData({
26462
26473
  groups: this.configs.groups,
26474
+ divergent: true
26463
26475
  });
26476
+ var activeDataGroupNames = this.model.getActiveDataGroupNames();
26464
26477
  // Update data on all bar groups
26465
26478
  var barGroups = svg
26466
26479
  .selectAll('g.bars')
@@ -26525,12 +26538,24 @@ var bar_stacked_StackedBar = /** @class */ (function (_super) {
26525
26538
  // Add the divider gap
26526
26539
  if (Math.abs(y1 - y0) > 0 &&
26527
26540
  Math.abs(y1 - y0) > options.bars.dividerSize) {
26528
- if (_this.services.cartesianScales.getOrientation() ===
26529
- CartesianOrientations.VERTICAL) {
26530
- y1 += 1;
26541
+ var barIsNegative = d[0] < 0 && d[1] <= 0;
26542
+ if (barIsNegative && activeDataGroupNames.length > 1) {
26543
+ if (_this.services.cartesianScales.getOrientation() ===
26544
+ CartesianOrientations.VERTICAL) {
26545
+ y1 += d[1] === 0 ? 2 : 1;
26546
+ }
26547
+ else {
26548
+ y1 -= d[1] === 0 ? 1 : 1;
26549
+ }
26531
26550
  }
26532
- else {
26533
- y1 -= 1;
26551
+ else if (!barIsNegative) {
26552
+ if (_this.services.cartesianScales.getOrientation() ===
26553
+ CartesianOrientations.VERTICAL) {
26554
+ y1 += 1;
26555
+ }
26556
+ else {
26557
+ y1 -= 1;
26558
+ }
26534
26559
  }
26535
26560
  }
26536
26561
  return tools_Tools.generateSVGPathString({ x0: x0, x1: x1, y0: y0, y1: y1 }, _this.services.cartesianScales.getOrientation());
@@ -29064,12 +29089,13 @@ var pie_Pie = /** @class */ (function (_super) {
29064
29089
  if (animate === void 0) { animate = true; }
29065
29090
  var self = this;
29066
29091
  var svg = this.getComponentContainer();
29092
+ var options = this.getOptions();
29093
+ var groupMapsTo = options.data.groupMapsTo;
29094
+ var valueMapsTo = options.pie.valueMapsTo;
29067
29095
  // remove any slices that are valued at 0 because they dont need to be rendered and will create extra padding
29068
29096
  var displayData = this.model
29069
29097
  .getDisplayData()
29070
- .filter(function (data) { return data.value > 0; });
29071
- var options = this.getOptions();
29072
- var groupMapsTo = options.data.groupMapsTo;
29098
+ .filter(function (data) { return data[valueMapsTo] > 0; });
29073
29099
  // Compute the outer radius needed
29074
29100
  var radius = this.computeRadius();
29075
29101
  this.arc = src_arc().innerRadius(this.getInnerRadius()).outerRadius(radius);
@@ -29079,7 +29105,7 @@ var pie_Pie = /** @class */ (function (_super) {
29079
29105
  .outerRadius(radius + configuration_non_customizable_pie.hoverArc.outerRadiusOffset);
29080
29106
  // Setup the pie layout
29081
29107
  var pieLayout = src_pie()
29082
- .value(function (d) { return d.value; })
29108
+ .value(function (d) { return d[valueMapsTo]; })
29083
29109
  .sort(tools_Tools.getProperty(options, 'pie', 'sortFunction'))
29084
29110
  .padAngle(configuration_non_customizable_pie.padAngle);
29085
29111
  // Add data to pie layout
@@ -29125,7 +29151,7 @@ var pie_Pie = /** @class */ (function (_super) {
29125
29151
  .attr('role', Roles.GRAPHICS_SYMBOL)
29126
29152
  .attr('aria-roledescription', 'slice')
29127
29153
  .attr('aria-label', function (d) {
29128
- return d.value + ", " + (tools_Tools.convertValueToPercentage(d.data.value, displayData) + '%');
29154
+ return d[valueMapsTo] + ", " + (tools_Tools.convertValueToPercentage(d.data[valueMapsTo], displayData, valueMapsTo) + '%');
29129
29155
  })
29130
29156
  // Tween
29131
29157
  .attrTween('d', function (a) {
@@ -29134,7 +29160,7 @@ var pie_Pie = /** @class */ (function (_super) {
29134
29160
  // Draw the slice labels
29135
29161
  var renderLabels = options.pie.labels.enabled;
29136
29162
  var labelData = renderLabels
29137
- ? pieLayoutData.filter(function (x) { return x.value > 0; })
29163
+ ? pieLayoutData.filter(function (x) { return x.data[valueMapsTo] > 0; })
29138
29164
  : [];
29139
29165
  var labelsGroup = dom_utils_DOMUtils.appendOrSelect(svg, 'g.labels')
29140
29166
  .attr('role', Roles.GROUP)
@@ -29158,8 +29184,7 @@ var pie_Pie = /** @class */ (function (_super) {
29158
29184
  if (options.pie.labels.formatter) {
29159
29185
  return options.pie.labels.formatter(d);
29160
29186
  }
29161
- return (tools_Tools.convertValueToPercentage(d.data.value, displayData) +
29162
- '%');
29187
+ return (tools_Tools.convertValueToPercentage(d.data[valueMapsTo], displayData, valueMapsTo) + '%');
29163
29188
  })
29164
29189
  // Calculate dimensions in order to transform
29165
29190
  .datum(function (d) {
@@ -29339,6 +29364,7 @@ var pie_Pie = /** @class */ (function (_super) {
29339
29364
  datum: datum,
29340
29365
  });
29341
29366
  var groupMapsTo = self.getOptions().data.groupMapsTo;
29367
+ var valueMapsTo = self.getOptions().pie.valueMapsTo;
29342
29368
  // Show tooltip
29343
29369
  self.services.events.dispatchEvent(Events.Tooltip.SHOW, {
29344
29370
  event: event,
@@ -29346,7 +29372,7 @@ var pie_Pie = /** @class */ (function (_super) {
29346
29372
  items: [
29347
29373
  {
29348
29374
  label: datum.data[groupMapsTo],
29349
- value: datum.data.value,
29375
+ value: datum.data[valueMapsTo],
29350
29376
  },
29351
29377
  ],
29352
29378
  });
@@ -29830,7 +29856,7 @@ var donut_Donut = /** @class */ (function (_super) {
29830
29856
  donutCenterFigure = this.model
29831
29857
  .getDisplayData()
29832
29858
  .reduce(function (accumulator, d) {
29833
- return accumulator + d.value;
29859
+ return accumulator + d[options.pie.valueMapsTo];
29834
29860
  }, 0);
29835
29861
  }
29836
29862
  // Remove commas from the current value string, and convert to an int
@@ -30677,6 +30703,26 @@ function constantZero() {
30677
30703
  return treemap;
30678
30704
  });
30679
30705
 
30706
+ // CONCATENATED MODULE: /home/runner/work/carbon-charts/carbon-charts/node_modules/d3-array/src/sum.js
30707
+ function sum_sum(values, valueof) {
30708
+ let sum = 0;
30709
+ if (valueof === undefined) {
30710
+ for (let value of values) {
30711
+ if (value = +value) {
30712
+ sum += value;
30713
+ }
30714
+ }
30715
+ } else {
30716
+ let index = -1;
30717
+ for (let value of values) {
30718
+ if (value = +valueof(value, ++index, values)) {
30719
+ sum += value;
30720
+ }
30721
+ }
30722
+ }
30723
+ return sum;
30724
+ }
30725
+
30680
30726
  // CONCATENATED MODULE: /home/runner/work/carbon-charts/carbon-charts/node_modules/@carbon/colors/es/index.js
30681
30727
  /**
30682
30728
  * Copyright IBM Corp. 2018, 2018
@@ -37790,6 +37836,7 @@ var bar_stacked_StackedBarChart = /** @class */ (function (_super) {
37790
37836
  new skeleton_Skeleton(this.model, this.services, {
37791
37837
  skeleton: Skeletons.VERT_OR_HORIZ,
37792
37838
  }),
37839
+ new zero_line_ZeroLine(this.model, this.services),
37793
37840
  ];
37794
37841
  var components = this.getAxisChartComponents(graphFrameComponents);
37795
37842
  return components;
@@ -38293,6 +38340,7 @@ var line_LineChart = /** @class */ (function (_super) {
38293
38340
  new line_Line(this.model, this.services),
38294
38341
  new scatter_Scatter(this.model, this.services, { handleThresholds: true }),
38295
38342
  new skeleton_lines_SkeletonLines(this.model, this.services),
38343
+ new zero_line_ZeroLine(this.model, this.services),
38296
38344
  ];
38297
38345
  var components = this.getAxisChartComponents(graphFrameComponents);
38298
38346
  return components;