@carbon/charts 0.53.1 → 0.53.2
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.
|
@@ -39,6 +39,7 @@ var AxisChartsTooltip = /** @class */ (function (_super) {
|
|
|
39
39
|
var options = this.getOptions();
|
|
40
40
|
var cartesianScales = this.services.cartesianScales;
|
|
41
41
|
var domainIdentifier = cartesianScales.getDomainIdentifier();
|
|
42
|
+
var dualAxes = cartesianScales.isDualAxes();
|
|
42
43
|
// Generate default tooltip
|
|
43
44
|
var groupMapsTo = options.data.groupMapsTo;
|
|
44
45
|
var domainLabel = cartesianScales.getDomainLabel();
|
|
@@ -48,6 +49,13 @@ var AxisChartsTooltip = /** @class */ (function (_super) {
|
|
|
48
49
|
if (data.length === 1) {
|
|
49
50
|
var datum = data[0];
|
|
50
51
|
var rangeIdentifier = cartesianScales.getRangeIdentifier(datum);
|
|
52
|
+
if (dualAxes) {
|
|
53
|
+
var position = cartesianScales.getRangeAxisPosition({
|
|
54
|
+
datum: datum,
|
|
55
|
+
groups: [datum[groupMapsTo]],
|
|
56
|
+
});
|
|
57
|
+
rangeLabel = cartesianScales.getScaleLabel(position);
|
|
58
|
+
}
|
|
51
59
|
var value = datum[rangeIdentifier];
|
|
52
60
|
items = __spreadArrays([
|
|
53
61
|
{
|
|
@@ -107,7 +115,6 @@ var AxisChartsTooltip = /** @class */ (function (_super) {
|
|
|
107
115
|
}),
|
|
108
116
|
}); })
|
|
109
117
|
.sort(function (a, b) { return b.value - a.value; }));
|
|
110
|
-
var dualAxes = cartesianScales.isDualAxes();
|
|
111
118
|
if (!dualAxes &&
|
|
112
119
|
Tools.getProperty(options, 'tooltip', 'showTotal') === true) {
|
|
113
120
|
// use the primary/only range id
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tooltip-axis.js","sourceRoot":"","sources":["tooltip-axis.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA,OAAO,EAAE,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CAAC,QAAQ;gBACT,KAAK,CAAC,WAAW,CAAC,OAAO,EAAE,SAAS,EAAE,WAAW,CAAC,KAAK,IAAI,EAC1D;gBACD,gCAAgC;gBAChC,IAAM,iBAAe,GAAG,eAAe,CAAC,kBAAkB,EAAE,CAAC;gBAC7D,KAAK,CAAC,IAAI,CAAC;oBACV,KAAK,EAAE,GAAG,CAAC,OAAO,EAAE,oBAAoB,CAAC,IAAI,OAAO;oBACpD,KAAK,EAAE,IAAI,CAAC,MAAM,CACjB,UAAC,WAAW,EAAE,KAAK;wBAClB,OAAA,WAAW,GAAG,KAAK,CAAC,iBAAe,CAAC;oBAApC,CAAoC,EACrC,CAAC,CACD;oBACD,IAAI,EAAE,IAAI;iBACV,CAAC,CAAC;aACH;SACD;QAED,OAAO,KAAK,CAAC;IACd,CAAC;IACF,wBAAC;AAAD,CAAC,AAxHD,CAAuC,OAAO,GAwH7C","sourcesContent":["import { Tooltip } from './tooltip';\nimport { ColorClassNameTypes } from '../../interfaces';\nimport { Tools } from '../../tools';\n\nimport { get } from 'lodash-es';\n\nexport class AxisChartsTooltip extends Tooltip {\n\tgetItems(e: CustomEvent) {\n\t\tif (e.detail.items) {\n\t\t\treturn e.detail.items;\n\t\t}\n\n\t\tconst data = e.detail.data;\n\t\tif (!data.length || !data[0]) {\n\t\t\treturn [];\n\t\t}\n\n\t\tconst options = this.getOptions();\n\t\tconst { cartesianScales } = this.services;\n\t\tconst domainIdentifier = cartesianScales.getDomainIdentifier();\n\t\tconst dualAxes = cartesianScales.isDualAxes();\n\n\t\t// Generate default tooltip\n\t\tconst { groupMapsTo } = options.data;\n\t\tconst domainLabel = cartesianScales.getDomainLabel();\n\t\tlet rangeLabel = cartesianScales.getRangeLabel();\n\n\t\tlet domainValue = data[0][domainIdentifier];\n\t\tlet items: any[];\n\t\tif (data.length === 1) {\n\t\t\tconst datum = data[0];\n\t\t\tconst rangeIdentifier = cartesianScales.getRangeIdentifier(datum);\n\n\t\t\tif (dualAxes) {\n\t\t\t\tconst position = cartesianScales.getRangeAxisPosition({\n\t\t\t\t\tdatum,\n\t\t\t\t\tgroups: [datum[groupMapsTo]],\n\t\t\t\t});\n\t\t\t\trangeLabel = cartesianScales.getScaleLabel(position);\n\t\t\t}\n\t\t\tconst value = datum[rangeIdentifier];\n\n\t\t\titems = [\n\t\t\t\t{\n\t\t\t\t\tlabel: domainLabel,\n\t\t\t\t\tvalue: domainValue,\n\t\t\t\t},\n\t\t\t\t...(Array.isArray(value) && value.length === 2\n\t\t\t\t\t? [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tlabel: 'Start',\n\t\t\t\t\t\t\t\tvalue: value[0],\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tlabel: 'End',\n\t\t\t\t\t\t\t\tvalue: value[1],\n\t\t\t\t\t\t\t},\n\t\t\t\t\t ]\n\t\t\t\t\t: [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tlabel: rangeLabel,\n\t\t\t\t\t\t\t\tvalue: datum[rangeIdentifier],\n\t\t\t\t\t\t\t},\n\t\t\t\t\t ]),\n\t\t\t];\n\n\t\t\tif (e.detail.additionalItems) {\n\t\t\t\te.detail.additionalItems.forEach((additionalItem) =>\n\t\t\t\t\titems.push({\n\t\t\t\t\t\tlabel: additionalItem.label,\n\t\t\t\t\t\tvalue: additionalItem.value,\n\t\t\t\t\t})\n\t\t\t\t);\n\t\t\t}\n\n\t\t\titems.push({\n\t\t\t\tlabel: options.tooltip.groupLabel,\n\t\t\t\tvalue: datum[groupMapsTo],\n\t\t\t\tcolor: this.model.getFillColor(datum[groupMapsTo]),\n\t\t\t\tclass: this.model.getColorClassName({\n\t\t\t\t\tclassNameTypes: [ColorClassNameTypes.TOOLTIP],\n\t\t\t\t\tdataGroupName: datum[groupMapsTo],\n\t\t\t\t}),\n\t\t\t});\n\t\t} else if (data.length > 1) {\n\t\t\titems = [\n\t\t\t\t{\n\t\t\t\t\tlabel: domainLabel,\n\t\t\t\t\tvalue: domainValue,\n\t\t\t\t},\n\t\t\t];\n\n\t\t\titems = items.concat(\n\t\t\t\tdata\n\t\t\t\t\t.map((datum) => ({\n\t\t\t\t\t\tlabel: datum[groupMapsTo],\n\t\t\t\t\t\tvalue: datum[cartesianScales.getRangeIdentifier(datum)],\n\t\t\t\t\t\tcolor: this.model.getFillColor(datum[groupMapsTo]),\n\t\t\t\t\t\tclass: this.model.getColorClassName({\n\t\t\t\t\t\t\tclassNameTypes: [ColorClassNameTypes.TOOLTIP],\n\t\t\t\t\t\t\tdataGroupName: datum[groupMapsTo],\n\t\t\t\t\t\t}),\n\t\t\t\t\t}))\n\t\t\t\t\t.sort((a, b) => b.value - a.value)\n\t\t\t);\n\n\t\t\tif (\n\t\t\t\t!dualAxes &&\n\t\t\t\tTools.getProperty(options, 'tooltip', 'showTotal') === true\n\t\t\t) {\n\t\t\t\t// use the primary/only range id\n\t\t\t\tconst rangeIdentifier = cartesianScales.getRangeIdentifier();\n\t\t\t\titems.push({\n\t\t\t\t\tlabel: get(options, 'tooltip.totalLabel') || 'Total',\n\t\t\t\t\tvalue: data.reduce(\n\t\t\t\t\t\t(accumulator, datum) =>\n\t\t\t\t\t\t\taccumulator + datum[rangeIdentifier],\n\t\t\t\t\t\t0\n\t\t\t\t\t),\n\t\t\t\t\tbold: true,\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\n\t\treturn items;\n\t}\n}\n"]}
|
package/package.json
CHANGED
package/tsconfig.tsbuildinfo
CHANGED
|
@@ -302,7 +302,7 @@
|
|
|
302
302
|
"signature": "03c2081ebe8e32a16aa2c3ed3ae49083ce863392e2bb8d1369c0fc29f938cf7a"
|
|
303
303
|
},
|
|
304
304
|
"../src/components/essentials/tooltip-axis.ts": {
|
|
305
|
-
"version": "
|
|
305
|
+
"version": "f116fa057340d29e3934a1ec632250fb534e5b8303098bce67caf1889f8cf275",
|
|
306
306
|
"signature": "d70e6454ac2a015783f9d10096feaab036b6f73479030f2808547d9579c885be"
|
|
307
307
|
},
|
|
308
308
|
"../src/components/axes/chart-clip.ts": {
|