@axdspub/axiom-charts 0.0.10 → 0.0.11

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.
@@ -434,7 +434,6 @@ var ChartRoot = /** @class */ (function () {
434
434
  case 1:
435
435
  _a.sent();
436
436
  this.showYAxes(yAxes);
437
- this.showYLabels(yAxes, this.plots);
438
437
  yAxesWidth = this.getYAxesWidth();
439
438
  chartWidth = this.getChartWidth();
440
439
  xRange = this.getXRange(chartWidth);
@@ -492,8 +491,6 @@ var ChartRoot = /** @class */ (function () {
492
491
  };
493
492
  ChartRoot.prototype.showYAxes = function (yAxes) {
494
493
  };
495
- ChartRoot.prototype.showYLabels = function (yAxes, plots) {
496
- };
497
494
  ChartRoot.prototype.showXAxes = function (xAxes) {
498
495
  };
499
496
  ChartRoot.prototype.draw = function () {
@@ -947,29 +944,39 @@ var AxiomChart = /** @class */ (function (_super) {
947
944
  axisSelection.append('g').call(axisG);
948
945
  }
949
946
  });
947
+ this.showYLabels(axes, this.plots);
950
948
  };
951
- AxiomChart.prototype.showYLabels = function (axes, plots) {
949
+ AxiomChart.prototype.getAxisLabel = function (axis, dimensionKey) {
952
950
  var _a;
953
- if (plots.length > 1) {
954
- return;
955
- }
956
- if (plots[0].type !== EPlotTypes.line) {
951
+ return (_a = axis.plots[0]) === null || _a === void 0 ? void 0 : _a.dimensions[dimensionKey].label;
952
+ };
953
+ AxiomChart.prototype.showYLabels = function (axes, plots) {
954
+ var _this = this;
955
+ var yLabelsAreSupportedForPlotType = [EPlotTypes.line, EPlotTypes.scatter, EPlotTypes.seasonal, EPlotTypes.area]
956
+ .find(function (type) { return type === plots[0].type; }) !== undefined;
957
+ if (plots.length === 0 || !yLabelsAreSupportedForPlotType) {
957
958
  return;
958
959
  }
959
960
  var chartElements = this.getChartElements();
960
- var label = (_a = axes[0].plots[0].dimensions.y.label) !== null && _a !== void 0 ? _a : '';
961
961
  if (chartElements === undefined) {
962
- return undefined;
962
+ return;
963
963
  }
964
964
  var svg = chartElements.svg;
965
965
  var axisSelection = svg.select('.y-axis').size() > 0 ? svg.select('.y-axis') : svg.append('g').attr('class', 'y-axis axis');
966
- axisSelection.append('text')
967
- .attr('class', 'y-label')
968
- .attr('text-anchor', 'end')
969
- .attr('dy', '.75rem')
970
- .attr('font-size', '.75rem')
971
- .attr('transform', 'rotate(-90)')
972
- .text(label);
966
+ // TODO: Don't hardcode these two vars
967
+ var axisWidth = 24;
968
+ var labelMargin = 3;
969
+ axes.forEach(function (axis) {
970
+ var _a;
971
+ axisSelection.append('text')
972
+ .attr('class', 'y-label')
973
+ .attr('transform', 'rotate(-90)')
974
+ .style('text-anchor', 'middle')
975
+ .attr('x', -1 * Math.floor(_this.getChartHeight() / 2))
976
+ .attr('y', "".concat(_this.getyAxisOffset(axis).x - axisWidth - labelMargin))
977
+ .attr('font-size', '.75rem')
978
+ .text((_a = _this.getAxisLabel(axis, 'y')) !== null && _a !== void 0 ? _a : '');
979
+ });
973
980
  };
974
981
  AxiomChart.prototype.getXAxisOffset = function (axis) {
975
982
  return __assign({ x: this.settings.margin.left, y: this.settings.height - this.settings.margin.bottom }, axis.offset);