@axdspub/axiom-charts 0.0.49 → 0.0.51

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/craco.config.js CHANGED
@@ -1,18 +1,16 @@
1
1
  const path = require('path')
2
+
2
3
  // someday, clean up the the FOUR! repeated declarations of aliases (others are is in tsconfig.paths.json => tsconfig.json and .storybook/main.ts)
3
4
  // https://stackoverflow.com/a/71892901
4
- console.log(path.resolve(__dirname, './src/'))
5
5
 
6
6
  module.exports = {
7
7
  webpack: {
8
8
  eslint: {
9
9
  enable: false
10
10
  },
11
- typescript: {
12
- enableTypeChecking: true
13
- },
14
11
  alias: {
15
- '@': path.resolve(__dirname, './src/')
12
+ '@': path.resolve(__dirname, './src/'),
13
+ '@WebCOOS': path.resolve(__dirname, 'src/Root/Images/WebCOOS/')
16
14
  },
17
15
  configure: {
18
16
  ignoreWarnings: [/Failed to parse source map/],
@@ -23,6 +21,10 @@ module.exports = {
23
21
  path: false,
24
22
  zlib: false
25
23
  }
24
+ },
25
+ module: {
26
+ // this silences a warning (Critical dependency: require function is used in a way in which dependencies cannot be statically extracted) that comes up with the cesium build included with @axdspubs/axiom-maps
27
+ unknownContextCritical: false
26
28
  }
27
29
  }
28
30
  },
@@ -3,7 +3,7 @@ import { extent, sum } from 'd3-array';
3
3
  import { groupBy, debounce } from 'lodash';
4
4
  import { create } from 'd3-selection';
5
5
  import * as d3 from 'd3';
6
- import { bisector } from 'd3';
6
+ import { curveStep, curveCardinal, curveCatmullRom, curveMonotoneX, curveNatural, bisector } from 'd3';
7
7
  import { scaleUtc, scaleLinear, scaleRadial } from 'd3-scale';
8
8
  import { axisLeft, axisBottom } from 'd3-axis';
9
9
  import { line, area, lineRadial, curveLinearClosed, pointRadial, areaRadial } from 'd3-shape';
@@ -54,6 +54,7 @@ var EPlotTypes;
54
54
  EPlotTypes["scatter"] = "scatter";
55
55
  EPlotTypes["box"] = "box";
56
56
  EPlotTypes["bar"] = "bar";
57
+ EPlotTypes["time_series_bar"] = "time_series_bar";
57
58
  EPlotTypes["stacked"] = "stacked";
58
59
  EPlotTypes["anomaly"] = "anomaly";
59
60
  EPlotTypes["curtain"] = "curtain";
@@ -84,9 +85,24 @@ class PlotRoot extends RequestItem {
84
85
  this.onDataLoad = props.onDataLoad;
85
86
  this.axisSettings = props.axisSettings;
86
87
  this.scrubSettings = Object.assign(Object.assign({}, this.scrubSettingsDefaults), props.scrubSettings);
88
+ this.interpolate = props.interpolate;
87
89
  this.legendSettings = Object.assign(Object.assign({}, this.legendSettingsDefaults), props.legendSettings);
88
90
  this.runtime = {};
89
91
  }
92
+ createAccessorGroupingsAtAxis(accessors, axis) {
93
+ const axisSetting = this.getAxisSetting(axis);
94
+ const accessProperties = axisSetting.accessProperties !== undefined ? axisSetting.accessProperties : {};
95
+ const accessorKeys = Object.keys(accessors).filter(k => k.startsWith(axis));
96
+ const accessorMap = Object.fromEntries(accessorKeys.map(k => [k, accessors[k]]));
97
+ Object.keys(accessProperties).forEach(k => {
98
+ const accessorKey = accessProperties[k];
99
+ const accFn = accessors[accessorKey];
100
+ if (accFn !== undefined) {
101
+ accessorMap[k] = accFn;
102
+ }
103
+ });
104
+ return accessorMap;
105
+ }
90
106
  getAxisSetting(axis) {
91
107
  if (this.axisSettings === undefined) {
92
108
  return {};
@@ -97,7 +113,7 @@ class PlotRoot extends RequestItem {
97
113
  }
98
114
  return axisSetting;
99
115
  }
100
- getDomainAccessor(axis) {
116
+ getDomainAccessorAtAxis(axis) {
101
117
  var _a, _b, _c, _d, _e, _f;
102
118
  const domainAccessors = ((_c = (_b = (_a = this.runtime) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.parsed) === null || _c === void 0 ? void 0 : _c.domainAccessors) !== undefined ? this.runtime.data.parsed.domainAccessors : {};
103
119
  const accessors = ((_f = (_e = (_d = this.runtime) === null || _d === void 0 ? void 0 : _d.data) === null || _e === void 0 ? void 0 : _e.parsed) === null || _f === void 0 ? void 0 : _f.accessors) !== undefined ? this.runtime.data.parsed.accessors : {};
@@ -111,24 +127,25 @@ class PlotRoot extends RequestItem {
111
127
  return (typeof d === 'number' || d instanceof Date || typeof d === 'string') ? d : d[axis];
112
128
  };
113
129
  }
130
+ getAvailableDomainAccessors() {
131
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
132
+ return ((_c = (_b = (_a = this.runtime) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.parsed) === null || _c === void 0 ? void 0 : _c.domainAccessors) !== undefined
133
+ ? this.runtime.data.parsed.domainAccessors
134
+ : ((_f = (_e = (_d = this.runtime) === null || _d === void 0 ? void 0 : _d.data) === null || _e === void 0 ? void 0 : _e.parsed) === null || _f === void 0 ? void 0 : _f.accessors) !== undefined
135
+ ? (_j = (_h = (_g = this.runtime) === null || _g === void 0 ? void 0 : _g.data) === null || _h === void 0 ? void 0 : _h.parsed) === null || _j === void 0 ? void 0 : _j.accessors
136
+ : {};
137
+ }
138
+ getDomainAccessorsAtAxis(axis) {
139
+ const accessors = this.getAvailableDomainAccessors();
140
+ return this.createAccessorGroupingsAtAxis(accessors, axis);
141
+ }
114
142
  getAvailableAccessors() {
115
143
  var _a, _b, _c;
116
144
  return ((_c = (_b = (_a = this.runtime) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.parsed) === null || _c === void 0 ? void 0 : _c.accessors) !== undefined ? this.runtime.data.parsed.accessors : {};
117
145
  }
118
146
  getAccessorsAtAxis(axis) {
119
147
  const accessors = this.getAvailableAccessors();
120
- const axisSetting = this.getAxisSetting(axis);
121
- const accessProperties = axisSetting.accessProperties !== undefined ? axisSetting.accessProperties : {};
122
- const accessorKeys = Object.keys(accessors).filter(k => k.startsWith(axis));
123
- const accessorMap = Object.fromEntries(accessorKeys.map(k => [k, accessors[k]]));
124
- Object.keys(accessProperties).forEach(k => {
125
- const accessorKey = accessProperties[k];
126
- const accFn = accessors[accessorKey];
127
- if (accFn !== undefined) {
128
- accessorMap[k] = accFn;
129
- }
130
- });
131
- return accessorMap;
148
+ return this.createAccessorGroupingsAtAxis(accessors, axis);
132
149
  }
133
150
  getAccessorAtAxis(axis) {
134
151
  const axisAccessors = this.getAccessorsAtAxis(axis);
@@ -147,7 +164,7 @@ class PlotRoot extends RequestItem {
147
164
  return __awaiter(this, void 0, void 0, function* () {
148
165
  const data = yield this.getData();
149
166
  const parsedData = ((_a = data === null || data === void 0 ? void 0 : data.parsed) === null || _a === void 0 ? void 0 : _a.data) !== undefined ? data.parsed.data : [];
150
- const accessor = this.getDomainAccessor(axis);
167
+ const accessor = this.getDomainAccessorAtAxis(axis);
151
168
  const values = parsedData
152
169
  .map((d) => {
153
170
  return accessor(d);
@@ -252,7 +269,12 @@ class ChartRoot {
252
269
  onDraw() {
253
270
  }
254
271
  getDomainForPlotImplementations(plotImplementations, axis) {
272
+ var _a, _b;
255
273
  return __awaiter(this, void 0, void 0, function* () {
274
+ const overrides = (_b = (_a = this.settings) === null || _a === void 0 ? void 0 : _a.axes) === null || _b === void 0 ? void 0 : _b[String(axis)];
275
+ if ((overrides === null || overrides === void 0 ? void 0 : overrides.domain) !== undefined) {
276
+ return overrides.domain;
277
+ }
256
278
  const domains = yield Promise.all(plotImplementations.map((p) => __awaiter(this, void 0, void 0, function* () {
257
279
  const domain = yield p.getDomain(axis);
258
280
  return domain;
@@ -310,8 +332,11 @@ class ChartRoot {
310
332
  const yAxesWidth = this.getYAxesWidth();
311
333
  return this.getWidth() - yAxesWidth - this.settings.margin.right;
312
334
  }
335
+ getXAxesGroups() {
336
+ return this.plotImplementations !== undefined ? this.getPlotImplementationGroups(this.plotImplementations, 'x') : {};
337
+ }
313
338
  getChartHeight() {
314
- const xGroups = this.plotImplementations !== undefined ? this.getPlotImplementationGroups(this.plotImplementations, 'x') : {};
339
+ const xGroups = this.getXAxesGroups();
315
340
  const xGroupCount = Object.keys(xGroups).length;
316
341
  return this.settings.height - this.settings.margin.top - (this.settings.margin.bottom * xGroupCount);
317
342
  }
@@ -347,7 +372,7 @@ class ChartRoot {
347
372
  })
348
373
  })) */
349
374
  const { margin } = this.settings;
350
- const xGroups = this.getPlotImplementationGroups(this.plotImplementations, 'x');
375
+ const xGroups = this.getXAxesGroups();
351
376
  const chartHeight = this.getChartHeight();
352
377
  const yGroups = this.getPlotImplementationGroups(this.plotImplementations, 'y');
353
378
  const yAxes = [];
@@ -482,16 +507,6 @@ class AxiomLine extends AxiomPlotRoot {
482
507
  super.onScrubEnd();
483
508
  };
484
509
  }
485
- getDomainAccessor(axis) {
486
- var _a, _b, _c;
487
- const accessors = ((_c = (_b = (_a = this.runtime) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.parsed) === null || _c === void 0 ? void 0 : _c.accessors) !== undefined ? this.runtime.data.parsed.accessors : {};
488
- if (accessors[axis] !== undefined) {
489
- return accessors[axis];
490
- }
491
- return (d) => {
492
- return (typeof d === 'number' || d instanceof Date || typeof d === 'string') ? d : d[axis];
493
- };
494
- }
495
510
  draw() {
496
511
  const _super = Object.create(null, {
497
512
  onLegendReady: { get: () => super.onLegendReady }
@@ -534,7 +549,7 @@ class AxiomLine extends AxiomPlotRoot {
534
549
  return 0;
535
550
  const v = yAccessor(d);
536
551
  const p = this.yScale(v);
537
- return p === undefined ? 0 : (p + this.offset.y);
552
+ return p === undefined ? 0 : (p /* + this.offset.y */);
538
553
  };
539
554
  const isDefined = (d) => {
540
555
  const v = yAccessor(d);
@@ -548,6 +563,21 @@ class AxiomLine extends AxiomPlotRoot {
548
563
  .x(xPosition)
549
564
  .y(yPosition)
550
565
  .defined(isDefined);
566
+ if (this.interpolate === 'step') {
567
+ line$1.curve(curveStep);
568
+ }
569
+ else if (this.interpolate === 'cardinal') {
570
+ line$1.curve(curveCardinal);
571
+ }
572
+ else if (this.interpolate === 'catmullRom') {
573
+ line$1.curve(curveCatmullRom);
574
+ }
575
+ else if (this.interpolate === 'monotone') {
576
+ line$1.curve(curveMonotoneX);
577
+ }
578
+ else if (this.interpolate === 'natural') {
579
+ line$1.curve(curveNatural);
580
+ }
551
581
  line$1.context(ctx);
552
582
  ctx.beginPath();
553
583
  if ((style === null || style === void 0 ? void 0 : style.strokeDash) !== undefined) {
@@ -608,12 +638,12 @@ class AxiomLine extends AxiomPlotRoot {
608
638
 
609
639
  class AxiomArea extends AxiomPlotRoot {
610
640
  getMaxAccessorAtAxis(axis) {
611
- const axisAccessors = this.getAccessorsAtAxis(axis);
641
+ const axisAccessors = this.getDomainAccessorsAtAxis(axis);
612
642
  const maxAccessor = axisAccessors[`${axis}1`];
613
643
  return maxAccessor;
614
644
  }
615
645
  getMinAccessorAtAxis(axis) {
616
- const axisAccessors = this.getAccessorsAtAxis(axis);
646
+ const axisAccessors = this.getDomainAccessorsAtAxis(axis);
617
647
  const minAccessor = axisAccessors[`${axis}0`];
618
648
  return minAccessor;
619
649
  }
@@ -697,12 +727,27 @@ class AxiomArea extends AxiomPlotRoot {
697
727
  area$1.x(makePositionFn(xAccessor, xScale, offset.x));
698
728
  }
699
729
  if (y0Accessor !== undefined && y1Accessor !== undefined) {
700
- area$1.y0(makePositionFn(y0Accessor, yScale, offset.y));
701
- area$1.y1(makePositionFn(y1Accessor, yScale, offset.y));
730
+ area$1.y0(makePositionFn(y0Accessor, yScale, 0.01));
731
+ area$1.y1(makePositionFn(y1Accessor, yScale, 0.01));
702
732
  area$1.defined(makeDefinedFn(y1Accessor));
703
733
  }
704
734
  else if (yAccessor !== undefined) {
705
- area$1.y(makePositionFn(yAccessor, yScale, offset.y));
735
+ area$1.y(makePositionFn(yAccessor, yScale, 0.01));
736
+ }
737
+ if (this.interpolate === 'step') {
738
+ area$1.curve(curveStep);
739
+ }
740
+ else if (this.interpolate === 'cardinal') {
741
+ area$1.curve(curveCardinal);
742
+ }
743
+ else if (this.interpolate === 'catmullRom') {
744
+ area$1.curve(curveCatmullRom);
745
+ }
746
+ else if (this.interpolate === 'monotone') {
747
+ area$1.curve(curveMonotoneX);
748
+ }
749
+ else if (this.interpolate === 'natural') {
750
+ area$1.curve(curveNatural);
706
751
  }
707
752
  area$1.context(ctx);
708
753
  ctx.beginPath();
@@ -749,16 +794,6 @@ class AxiomScatter extends AxiomPlotRoot {
749
794
  super.onScrubEnd();
750
795
  };
751
796
  }
752
- getDomainAccessor(axis) {
753
- var _a, _b, _c;
754
- const accessors = ((_c = (_b = (_a = this.runtime) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.parsed) === null || _c === void 0 ? void 0 : _c.accessors) !== undefined ? this.runtime.data.parsed.accessors : {};
755
- if (accessors[axis] !== undefined) {
756
- return accessors[axis];
757
- }
758
- return (d) => {
759
- return (typeof d === 'number' || d instanceof Date || typeof d === 'string') ? d : d[axis];
760
- };
761
- }
762
797
  draw() {
763
798
  const _super = Object.create(null, {
764
799
  onLegendReady: { get: () => super.onLegendReady }
@@ -798,7 +833,7 @@ class AxiomScatter extends AxiomPlotRoot {
798
833
  return 0;
799
834
  const v = yAccessor(d);
800
835
  const p = this.yScale(v);
801
- return p === undefined ? 0 : (p + this.offset.y);
836
+ return p === undefined ? 0 : (p /* + this.offset.y */);
802
837
  };
803
838
  const isDefined = (d) => {
804
839
  const v = yAccessor(d);
@@ -851,7 +886,7 @@ class AxiomScatter extends AxiomPlotRoot {
851
886
  }
852
887
  }
853
888
 
854
- class AxiomBar extends AxiomPlotRoot {
889
+ let AxiomBar$1 = class AxiomBar extends AxiomPlotRoot {
855
890
  constructor(props) {
856
891
  super(props);
857
892
  this.legendHeight = 12;
@@ -1049,13 +1084,152 @@ class AxiomBar extends AxiomPlotRoot {
1049
1084
  }
1050
1085
  return subgroupScales;
1051
1086
  }
1087
+ };
1088
+
1089
+ class AxiomBar extends AxiomPlotRoot {
1090
+ getMaxAccessorAtAxis(axis) {
1091
+ const axisAccessors = this.getDomainAccessorsAtAxis(axis);
1092
+ const maxAccessor = axisAccessors[`${axis}1`];
1093
+ return maxAccessor;
1094
+ }
1095
+ getMinAccessorAtAxis(axis) {
1096
+ const axisAccessors = this.getDomainAccessorsAtAxis(axis);
1097
+ const minAccessor = axisAccessors[`${axis}0`];
1098
+ return minAccessor;
1099
+ }
1100
+ getDomainAccessor(axis) {
1101
+ const minAccessor = this.getMinAccessorAtAxis(axis);
1102
+ const maxAccessor = this.getMaxAccessorAtAxis(axis);
1103
+ if (minAccessor !== undefined && maxAccessor !== undefined) {
1104
+ return (d) => {
1105
+ return [
1106
+ minAccessor(d),
1107
+ maxAccessor(d)
1108
+ ];
1109
+ };
1110
+ }
1111
+ const accessor = this.getAccessorAtAxis(axis);
1112
+ if (accessor !== undefined) {
1113
+ return accessor;
1114
+ }
1115
+ return (d) => {
1116
+ return (d instanceof Date || d === null || typeof d === 'number' || typeof d === 'string') ? d : sum(Object.values(d));
1117
+ };
1118
+ }
1119
+ draw() {
1120
+ const _super = Object.create(null, {
1121
+ onLegendReady: { get: () => super.onLegendReady }
1122
+ });
1123
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
1124
+ return __awaiter(this, void 0, void 0, function* () {
1125
+ const style = this.style !== undefined ? this.style : {};
1126
+ const data = yield this.getData();
1127
+ const parsedData = (_a = data === null || data === void 0 ? void 0 : data.parsed) === null || _a === void 0 ? void 0 : _a.data;
1128
+ const xAccessors = this.getAccessorsAtAxis('x');
1129
+ const xAccessor = this.getAccessorAtAxis('x');
1130
+ const x0Accessor = xAccessors.x0;
1131
+ const x1Accessor = xAccessors.x1;
1132
+ const yAccessors = this.getAccessorsAtAxis('y');
1133
+ const yAccessor = this.getAccessorAtAxis('y');
1134
+ const y0Accessor = yAccessors.y0;
1135
+ const y1Accessor = yAccessors.y1;
1136
+ const offset = {
1137
+ x: ((_d = (_c = (_b = this === null || this === void 0 ? void 0 : this.axes) === null || _b === void 0 ? void 0 : _b.x) === null || _c === void 0 ? void 0 : _c.offset) === null || _d === void 0 ? void 0 : _d.x) !== undefined ? this.axes.x.offset.x : 0,
1138
+ y: ((_g = (_f = (_e = this === null || this === void 0 ? void 0 : this.axes) === null || _e === void 0 ? void 0 : _e.y) === null || _f === void 0 ? void 0 : _f.offset) === null || _g === void 0 ? void 0 : _g.y) !== undefined ? this.axes.y.offset.y : 0
1139
+ };
1140
+ const chart = this.chart;
1141
+ const ctx = chart.getCanvasContext();
1142
+ if (ctx === null) {
1143
+ return undefined;
1144
+ }
1145
+ const xAxisScale = (_j = (_h = this === null || this === void 0 ? void 0 : this.axes) === null || _h === void 0 ? void 0 : _h.x) === null || _j === void 0 ? void 0 : _j.scale;
1146
+ const yAxisScale = (_l = (_k = this === null || this === void 0 ? void 0 : this.axes) === null || _k === void 0 ? void 0 : _k.y) === null || _l === void 0 ? void 0 : _l.scale;
1147
+ if (xAxisScale === undefined ||
1148
+ yAxisScale === undefined ||
1149
+ parsedData === undefined ||
1150
+ (xAccessor === undefined && x0Accessor === undefined && x1Accessor === undefined) ||
1151
+ (yAccessor === undefined && y0Accessor === undefined && y1Accessor === undefined)) {
1152
+ console.log('Missing one of: xAxisScale, yAxisScale, parsedData, xAccessor(s), yAccessor(s)');
1153
+ return undefined;
1154
+ }
1155
+ const xScale = chart.getD3XScale(xAxisScale);
1156
+ const yScale = chart.getD3YScale(yAxisScale);
1157
+ const makePositionFn = (acc, d3Scale, offset) => {
1158
+ return (d) => {
1159
+ const v = acc(d);
1160
+ const p = d3Scale(v);
1161
+ return p === undefined ? 0 : (p + offset);
1162
+ };
1163
+ };
1164
+ ctx.fillStyle = style.fill !== undefined ? style.fill : '#EDEDED';
1165
+ const rect = {};
1166
+ if (x0Accessor !== undefined && x1Accessor !== undefined) {
1167
+ rect.x0 = makePositionFn(x0Accessor, xScale, offset.x);
1168
+ rect.x1 = makePositionFn(x1Accessor, xScale, offset.x);
1169
+ }
1170
+ else if (xAccessor !== undefined) {
1171
+ rect.x = makePositionFn(xAccessor, xScale, offset.x);
1172
+ }
1173
+ if (y0Accessor !== undefined && y1Accessor !== undefined) {
1174
+ rect.y0 = makePositionFn(y0Accessor, yScale, 0.01);
1175
+ rect.y1 = makePositionFn(y1Accessor, yScale, 0.01);
1176
+ }
1177
+ else if (yAccessor !== undefined) {
1178
+ rect.y = makePositionFn(yAccessor, yScale, 0.01);
1179
+ }
1180
+ ctx.beginPath();
1181
+ const isVert = !!(rect.x0 !== undefined && rect.x1 !== undefined);
1182
+ const height = Math.abs(yAxisScale.range[1] - yAxisScale.range[0]);
1183
+ const width = Math.abs(xAxisScale.range[1] - xAxisScale.range[0]);
1184
+ // const barSpace = 2
1185
+ const barSpacePercent = 20;
1186
+ const visibleData = parsedData.filter(row => {
1187
+ return isVert
1188
+ ? +rect.y(row) >= yAxisScale.range[0] && +rect.y(row) <= yAxisScale.range[1]
1189
+ : +rect.x(row) >= (xAxisScale.range[0] + offset.x) && +rect.x(row) <= (xAxisScale.range[1] + offset.x);
1190
+ });
1191
+ const barSize = Math.round(((isVert ? height : width) - visibleData.length) / visibleData.length);
1192
+ const defaultSize = Math.max(1, barSize - barSize * (barSpacePercent / 100));
1193
+ visibleData.forEach((row, i) => {
1194
+ if (isVert) {
1195
+ const xVal = rect.x0(row);
1196
+ if (xVal !== undefined && xVal !== null) {
1197
+ const xW = Math.abs(rect.x1(row) - xVal);
1198
+ const yVal = rect.y(row);
1199
+ const yH = defaultSize;
1200
+ ctx.rect(xVal, yVal, xW, yH);
1201
+ }
1202
+ }
1203
+ else {
1204
+ const y0 = rect.y0(row);
1205
+ const y1 = rect.y1(row);
1206
+ if (y0 !== undefined && y0 !== null && y1 !== undefined && y1 !== null) {
1207
+ const xVal = rect.x(row) - defaultSize / 2;
1208
+ // add per feature style option
1209
+ // ctx.fillStyle = i % 2 === 0 ? '#FF0000' : '#006699'
1210
+ ctx.fillRect(xVal, y0, defaultSize, y1 - y0);
1211
+ }
1212
+ }
1213
+ // ctx.rect(rect.x0(row),row.y0(row),)
1214
+ });
1215
+ ctx.fill();
1216
+ if (((_m = this.axes) === null || _m === void 0 ? void 0 : _m.y) !== undefined && !((_o = this.legendSettings.hide) !== null && _o !== void 0 ? _o : false)) {
1217
+ _super.onLegendReady.call(this, [{
1218
+ id: this.axes.y.key,
1219
+ label: (_p = chart.getAxisLabel(this.axes.y, 'y')) !== null && _p !== void 0 ? _p : this.axes.y.key,
1220
+ style: { backgroundColor: ctx.fillStyle }
1221
+ }]);
1222
+ }
1223
+ });
1224
+ }
1052
1225
  }
1053
1226
 
1054
1227
  const chartTypes = {
1055
1228
  Line: AxiomLine,
1056
1229
  Area: AxiomArea,
1057
1230
  Scatter: AxiomScatter,
1058
- Bar: AxiomBar
1231
+ Bar: AxiomBar,
1232
+ CategoricalBar: AxiomBar$1
1059
1233
  };
1060
1234
 
1061
1235
  function styleInject(css, ref) {
@@ -1180,7 +1354,12 @@ class AxiomChart extends ChartRoot {
1180
1354
  if ((axis === null || axis === void 0 ? void 0 : axis.scale) !== undefined) {
1181
1355
  const axisG = this.getYAxis(axis, axisSettings, index);
1182
1356
  const axisSelection = svg.select('.y-axis').size() > 0 ? svg.select('.y-axis') : svg.append('g').attr('class', 'y-axis axis');
1183
- axisSelection.append('g').call(axisG);
1357
+ const newAxis = axisSelection.append('g').call(axisG);
1358
+ const allPlotsUseSameYAxis = axis.plots.length === this.plots.length;
1359
+ if (!allPlotsUseSameYAxis) {
1360
+ const plotColor = this.getAxisColor(axis);
1361
+ newAxis.attr('stroke', plotColor);
1362
+ }
1184
1363
  }
1185
1364
  });
1186
1365
  if (this.settings.layout === 'timeseries') {
@@ -1219,7 +1398,7 @@ class AxiomChart extends ChartRoot {
1219
1398
  });
1220
1399
  }
1221
1400
  getXAxisOffset(axis) {
1222
- return Object.assign({ x: this.settings.margin.left, y: this.settings.height - this.settings.margin.bottom }, axis.offset);
1401
+ return Object.assign({ x: this.settings.margin.left, y: this.settings.height + this.settings.margin.top }, axis.offset);
1223
1402
  }
1224
1403
  getyAxisOffset(axis) {
1225
1404
  return Object.assign({ x: this.settings.margin.left, y: this.settings.margin.top }, axis.offset);
@@ -1236,13 +1415,19 @@ class AxiomChart extends ChartRoot {
1236
1415
  const axisSettings = this.settings.axes === undefined ? {} : (_a = this.settings.axes[axis.key]) !== null && _a !== void 0 ? _a : {};
1237
1416
  const axisG = this.getXAxis(axis, axisSettings);
1238
1417
  const axisSelection = svg.select('.x-axis').size() > 0 ? svg.select('.x-axis') : svg.append('g').attr('class', 'x-axis axis');
1239
- axisSelection.append('g').call(axisG);
1418
+ const newAxis = axisSelection.append('g').call(axisG);
1419
+ const allPlotsUseSameYAxis = axis.plots.length === this.plots.length;
1420
+ if (!allPlotsUseSameYAxis) {
1421
+ const plotColor = this.getAxisColor(axis);
1422
+ newAxis.attr('stroke', plotColor);
1423
+ }
1240
1424
  }
1241
1425
  });
1242
1426
  }
1243
1427
  getCanvasContext() {
1244
- if (this.chartElements !== undefined) {
1245
- const { canvas } = this.chartElements;
1428
+ const chartElements = this.getChartElements();
1429
+ if (chartElements !== undefined) {
1430
+ const { canvas } = chartElements;
1246
1431
  const node = canvas.node();
1247
1432
  if (node !== undefined && node !== null) {
1248
1433
  return node.getContext('2d');
@@ -1417,6 +1602,18 @@ class AxiomChart extends ChartRoot {
1417
1602
  var _a;
1418
1603
  return (_a = style === null || style === void 0 ? void 0 : style.strokeColor) !== null && _a !== void 0 ? _a : '#333';
1419
1604
  }
1605
+ getAxisColor(axis) {
1606
+ var _a, _b;
1607
+ let plot = axis.plots.find(plot => { var _a; return ((_a = plot.style) === null || _a === void 0 ? void 0 : _a.fill) !== undefined; });
1608
+ if (plot !== undefined) {
1609
+ return (_a = plot.style) === null || _a === void 0 ? void 0 : _a.fill;
1610
+ }
1611
+ plot = axis.plots.find(plot => { var _a; return ((_a = plot.style) === null || _a === void 0 ? void 0 : _a.strokeColor) !== undefined; });
1612
+ if (plot !== undefined) {
1613
+ return (_b = plot.style) === null || _b === void 0 ? void 0 : _b.strokeColor;
1614
+ }
1615
+ return '#000';
1616
+ }
1420
1617
  getPlotStrokeWidth(style) {
1421
1618
  var _a;
1422
1619
  return (_a = style === null || style === void 0 ? void 0 : style.strokeWidth) !== null && _a !== void 0 ? _a : 1;