@plotdb/chart 3.10.1 → 3.13.0

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
@@ -1,5 +1,56 @@
1
1
  # Change Logs
2
2
 
3
+ ## v3.13.0
4
+
5
+ - empty state: when there is no data, the core writes one line in the middle of the plot area.
6
+ `common.empty` configures it ( `enabled`, `text`, `color`, `opacity`, `font.size` ), and the
7
+ text falls back through `cfg` -> i18n module -> a built-in dictionary ( en / zh-TW / zh-CN / ja ),
8
+ the same chain the legend uses. drawn by the core rather than by each chart on purpose: each
9
+ chart doing its own would misalign, and alignment is the one thing this kind of hint has to get
10
+ right. the core only ever has one message to give - it sees the raw the host handed it, so it
11
+ cannot tell "there was never any data" from "everything got filtered out", and that is fine:
12
+ the second is also "no data to show". a chart whose backdrop still means something without data
13
+ ( a map, say ) overrides `common.empty.enabled`'s default in its own `mod.config`.
14
+ charts with no empty data are untouched - no node is created at all
15
+
16
+
17
+ ## v3.12.0
18
+
19
+ - brush: `common.brush` styles the selection rectangle and the handles ( `fill`, `fillOpacity`,
20
+ `stroke`, `strokeOpacity`, `strokeWidth`, `handleFill`, `handleOpacity` ). d3's convention is a
21
+ light fill with a white edge, which on a dark theme reads as a glowing block, and until now the
22
+ only way out was for the host to reach into the chart block's own DOM with CSS. the node
23
+ structure ( `rect.overlay` / `rect.selection` / `rect.handle` ) belongs to `utils.brush`, so the
24
+ core styles it directly and charts pass nothing down. every property defaults to unset and an
25
+ unset property is not touched at all, so the serialized output of a chart that doesn't configure
26
+ it is unchanged - including `@makechart/bar`'s own `shape-rendering` on the selection.
27
+ the handles are transparent by default ( they are hit areas ); `handleFill` makes them visible
28
+
29
+
30
+ ## v3.11.0
31
+
32
+ - axis: `label.direction` gains `angled` and `auto`, plus `label.angle` ( degrees, default 45 ).
33
+ `angled` anchors each label's end at its tick and trails it down-left, the usual d3 convention;
34
+ the overlap test uses the label's projection along the axis ( `w·cos + h·sin` ) rather than its
35
+ width. `auto` tries horizontal, then angled, then vertical, and only falls back to thinning when
36
+ none of them fit - labels that don't fit horizontally used to be dropped outright, with no way
37
+ to ask for a rotation first. default stays `horizontal`, so nothing moves unless asked
38
+ - annotation: `common.annotation` draws notes and reference lines over the plot area, in two
39
+ deliberately separate coordinate spaces. `notes` are view-space - `{x, y}` are 0..1 of the plot
40
+ area, so they survive a resize and need nothing from the chart. `reference` is data-space -
41
+ `{axis, value, label}` asks the new `space` scope where that value lands, and a chart that
42
+ hasn't implemented the scope simply draws nothing. a reference line outside the current domain
43
+ is skipped rather than drawn over the axis. the two arrays are not in the config schema ( that
44
+ describes scalars, for konfig to build forms from ); only the styling is
45
+ - new `space` scope: `space.x(v)` / `space.y(v)` map a data value to plot-area coordinates, and
46
+ return null by default. the core does not own the scales - every chart builds its own - so this
47
+ is the only general way to ask. charts opt in with `mod.space`. `@makechart/line` implements it
48
+ - legend: new `actions` ( default true ) controls the "select all / none" shortcuts on their own.
49
+ `selectable` used to gate both whether items could be clicked and whether those two buttons
50
+ showed, so "clickable legend without the buttons" was impossible - in a small card the buttons
51
+ wrap and break the layout. `selectable` now only governs clicking
52
+
53
+
3
54
  ## v3.10.1
4
55
 
5
56
  - bin: `bin.parse` skips `size` bindings that use the same field as `value` ( summing the binned field
package/bundle.js CHANGED
@@ -899,7 +899,211 @@ var module = {exports: {}};
899
899
  }
900
900
  this._syncAnim();
901
901
  if (this.mod.render) {
902
- return this.mod.render.apply(this);
902
+ this.mod.render.apply(this);
903
+ }
904
+ this._brushStyle();
905
+ this._empty();
906
+ return this._anno();
907
+ },
908
+ _emptyText: function(){
909
+ var cfg, k, i, r, lng, res;
910
+ cfg = ((this.cfg || {}).common || {}).empty || {};
911
+ if (cfg.text) {
912
+ return cfg.text;
913
+ }
914
+ k = chart.i18nNs + ":text";
915
+ i = (typeof block != 'undefined' && block !== null) && block.i18n && block.i18n.module ? block.i18n.module : null;
916
+ if (i && i.t && (r = i.t(k)) && r !== k && r !== 'text') {
917
+ return r;
918
+ }
919
+ lng = (i ? i.language || i.lng : null) || (typeof document != 'undefined' && document !== null ? document.documentElement.lang : '') || 'en';
920
+ res = chart.i18n[lng] || chart.i18n[lng.split('-')[0]] || (/^zh/i.exec(lng) ? chart.i18n[/cn|hans|sg/i.exec(lng) ? 'zh-CN' : 'zh-TW'] : void 8) || chart.i18n.en;
921
+ return res.text;
922
+ },
923
+ _empty: function(){
924
+ var cfg, show, box, t;
925
+ cfg = ((this.cfg || {}).common || {}).empty || {};
926
+ show = (cfg.enabled != null ? !!cfg.enabled : true) && !(this.data || []).length;
927
+ if (!this.svg) {
928
+ return;
929
+ }
930
+ if (!show) {
931
+ if (this._emptyG && this._emptyG.parentNode) {
932
+ this._emptyG.parentNode.removeChild(this._emptyG);
933
+ }
934
+ return;
935
+ }
936
+ if (!this._emptyG) {
937
+ this._emptyG = document.createElementNS(svgns, 'g');
938
+ this._emptyG.setAttribute('data-type', 'empty');
939
+ this._emptyG.style.pointerEvents = 'none';
940
+ }
941
+ this.svg.appendChild(this._emptyG);
942
+ this._emptyG.textContent = '';
943
+ box = this._annoBox();
944
+ t = document.createElementNS(svgns, 'text');
945
+ t.setAttribute('x', box.x + box.width / 2);
946
+ t.setAttribute('y', box.y + box.height / 2);
947
+ t.setAttribute('text-anchor', 'middle');
948
+ t.setAttribute('dominant-baseline', 'middle');
949
+ t.style.fill = cfg.color || 'currentColor';
950
+ t.style.opacity = cfg.opacity != null ? cfg.opacity : 0.45;
951
+ if ((cfg.font || {}).size) {
952
+ t.style.fontSize = cfg.font.size + "";
953
+ }
954
+ t.textContent = this._emptyText();
955
+ return this._emptyG.appendChild(t);
956
+ },
957
+ _brushStyle: function(){
958
+ var cfg, set, i$, ref$, len$, n, results$ = [];
959
+ cfg = ((this.cfg || {}).common || {}).brush || {};
960
+ if (!this.svg) {
961
+ return;
962
+ }
963
+ set = function(n, k, v){
964
+ if (v != null && v !== '') {
965
+ return n.setAttribute(k, v);
966
+ }
967
+ };
968
+ for (i$ = 0, len$ = (ref$ = this.svg.querySelectorAll('rect.selection')).length; i$ < len$; ++i$) {
969
+ n = ref$[i$];
970
+ set(n, 'fill', cfg.fill);
971
+ set(n, 'fill-opacity', cfg.fillOpacity);
972
+ set(n, 'stroke', cfg.stroke);
973
+ set(n, 'stroke-opacity', cfg.strokeOpacity);
974
+ set(n, 'stroke-width', cfg.strokeWidth);
975
+ }
976
+ for (i$ = 0, len$ = (ref$ = this.svg.querySelectorAll('rect.handle')).length; i$ < len$; ++i$) {
977
+ n = ref$[i$];
978
+ set(n, 'fill', cfg.handleFill);
979
+ results$.push(set(n, 'fill-opacity', cfg.handleOpacity));
980
+ }
981
+ return results$;
982
+ },
983
+ _annoBox: function(){
984
+ var b;
985
+ if (this.layout) {
986
+ try {
987
+ b = this.layout.getBox('view');
988
+ if (b && b.width && b.height) {
989
+ return b;
990
+ }
991
+ } catch (e$) {}
992
+ }
993
+ return {
994
+ x: 0,
995
+ y: 0,
996
+ width: (this.box || {}).width || 0,
997
+ height: (this.box || {}).height || 0
998
+ };
999
+ },
1000
+ _anno: function(){
1001
+ var cfg, enabled, notes, refs, box, font, textOf, i$, len$, n, x, y, r, dir, v, e, ln, ref$, x1, y1, x2, y2, lx, ly, anchor, baseline, this$ = this, results$ = [];
1002
+ cfg = ((this.cfg || {}).common || {}).annotation || {};
1003
+ enabled = cfg.enabled != null ? !!cfg.enabled : true;
1004
+ notes = enabled
1005
+ ? cfg.notes || []
1006
+ : [];
1007
+ refs = enabled
1008
+ ? cfg.reference || []
1009
+ : [];
1010
+ if (!this.svg) {
1011
+ return;
1012
+ }
1013
+ if (!(notes.length || refs.length)) {
1014
+ if (this._annoG && this._annoG.parentNode) {
1015
+ this._annoG.parentNode.removeChild(this._annoG);
1016
+ }
1017
+ return;
1018
+ }
1019
+ if (!this._annoG) {
1020
+ this._annoG = document.createElementNS(svgns, 'g');
1021
+ this._annoG.setAttribute('data-type', 'annotation');
1022
+ this._annoG.style.pointerEvents = 'none';
1023
+ }
1024
+ this.svg.appendChild(this._annoG);
1025
+ this._annoG.textContent = '';
1026
+ box = this._annoBox();
1027
+ font = cfg.font || {};
1028
+ textOf = function(o, x, y, anchor, baseline){
1029
+ var t;
1030
+ t = document.createElementNS(svgns, 'text');
1031
+ t.setAttribute('x', x);
1032
+ t.setAttribute('y', y);
1033
+ t.setAttribute('text-anchor', anchor);
1034
+ t.setAttribute('dominant-baseline', baseline);
1035
+ t.style.fill = o.color || cfg.color || 'currentColor';
1036
+ if (o.size || font.size) {
1037
+ t.style.fontSize = (o.size || font.size) + "";
1038
+ }
1039
+ t.style.opacity = o.opacity != null
1040
+ ? o.opacity
1041
+ : cfg.opacity != null ? cfg.opacity : 1;
1042
+ t.textContent = o.text + "";
1043
+ this$._annoG.appendChild(t);
1044
+ return t;
1045
+ };
1046
+ for (i$ = 0, len$ = notes.length; i$ < len$; ++i$) {
1047
+ n = notes[i$];
1048
+ if (!(n && n.text != null)) {
1049
+ continue;
1050
+ }
1051
+ x = box.x + box.width * (n.x != null ? n.x : 0.5);
1052
+ y = box.y + box.height * (n.y != null ? n.y : 0.5);
1053
+ textOf(n, x, y, n.align || 'middle', n.baseline || 'middle');
1054
+ }
1055
+ for (i$ = 0, len$ = refs.length; i$ < len$; ++i$) {
1056
+ r = refs[i$];
1057
+ if (!r) {
1058
+ continue;
1059
+ }
1060
+ dir = r.axis === 'x' ? 'x' : 'y';
1061
+ v = (fn$.call(this));
1062
+ if (!(v != null) || isNaN(v)) {
1063
+ continue;
1064
+ }
1065
+ if (v < 0 || v > (dir === 'y'
1066
+ ? box.height
1067
+ : box.width)) {
1068
+ continue;
1069
+ }
1070
+ ln = document.createElementNS(svgns, 'line');
1071
+ ref$ = dir === 'y'
1072
+ ? [box.x, box.y + v, box.x + box.width, box.y + v]
1073
+ : [box.x + v, box.y, box.x + v, box.y + box.height], x1 = ref$[0], y1 = ref$[1], x2 = ref$[2], y2 = ref$[3];
1074
+ ln.setAttribute('x1', x1);
1075
+ ln.setAttribute('y1', y1);
1076
+ ln.setAttribute('x2', x2);
1077
+ ln.setAttribute('y2', y2);
1078
+ import$(ln.style, {
1079
+ stroke: r.color || cfg.color || 'currentColor',
1080
+ strokeWidth: r.width != null ? r.width : 1,
1081
+ strokeDasharray: r.dash != null ? r.dash : '4 3',
1082
+ opacity: r.opacity != null
1083
+ ? r.opacity
1084
+ : cfg.opacity != null ? cfg.opacity : 0.6
1085
+ });
1086
+ this._annoG.appendChild(ln);
1087
+ if (r.label != null) {
1088
+ ref$ = dir === 'y'
1089
+ ? [box.x + box.width - 2, box.y + v - 3, 'end', 'auto']
1090
+ : [box.x + v + 3, box.y + 2, 'start', 'hanging'], lx = ref$[0], ly = ref$[1], anchor = ref$[2], baseline = ref$[3];
1091
+ results$.push(textOf({
1092
+ text: r.label,
1093
+ color: r.color,
1094
+ size: r.size,
1095
+ opacity: r.opacity
1096
+ }, lx, ly, anchor, baseline));
1097
+ }
1098
+ }
1099
+ return results$;
1100
+ function fn$(){
1101
+ try {
1102
+ return this.space[dir](r.value);
1103
+ } catch (e$) {
1104
+ e = e$;
1105
+ return null;
1106
+ }
903
1107
  }
904
1108
  },
905
1109
  destroy: function(){
@@ -1390,10 +1594,137 @@ var module = {exports: {}};
1390
1594
  type: 'color',
1391
1595
  'default': 'transparent'
1392
1596
  }
1597
+ },
1598
+ empty: {
1599
+ enabled: {
1600
+ type: 'boolean',
1601
+ 'default': true
1602
+ },
1603
+ text: {
1604
+ type: 'text',
1605
+ 'default': ''
1606
+ },
1607
+ color: {
1608
+ type: 'color',
1609
+ 'default': 'currentColor'
1610
+ },
1611
+ opacity: {
1612
+ type: 'number',
1613
+ 'default': 0.45,
1614
+ min: 0,
1615
+ max: 1,
1616
+ step: 0.05
1617
+ },
1618
+ font: {
1619
+ size: {
1620
+ type: 'quantity',
1621
+ 'default': '',
1622
+ units: [{
1623
+ name: 'em',
1624
+ max: 10,
1625
+ step: 0.01,
1626
+ 'default': 1
1627
+ }]
1628
+ }
1629
+ }
1630
+ },
1631
+ brush: {
1632
+ fill: {
1633
+ type: 'color',
1634
+ 'default': ''
1635
+ },
1636
+ fillOpacity: {
1637
+ type: 'number',
1638
+ 'default': '',
1639
+ min: 0,
1640
+ max: 1,
1641
+ step: 0.05
1642
+ },
1643
+ stroke: {
1644
+ type: 'color',
1645
+ 'default': ''
1646
+ },
1647
+ strokeOpacity: {
1648
+ type: 'number',
1649
+ 'default': '',
1650
+ min: 0,
1651
+ max: 1,
1652
+ step: 0.05
1653
+ },
1654
+ strokeWidth: {
1655
+ type: 'number',
1656
+ 'default': '',
1657
+ min: 0,
1658
+ max: 20,
1659
+ step: 0.5
1660
+ },
1661
+ handleFill: {
1662
+ type: 'color',
1663
+ 'default': ''
1664
+ },
1665
+ handleOpacity: {
1666
+ type: 'number',
1667
+ 'default': '',
1668
+ min: 0,
1669
+ max: 1,
1670
+ step: 0.05
1671
+ }
1672
+ },
1673
+ annotation: {
1674
+ enabled: {
1675
+ type: 'boolean',
1676
+ 'default': true
1677
+ },
1678
+ color: {
1679
+ type: 'color',
1680
+ 'default': 'currentColor'
1681
+ },
1682
+ opacity: {
1683
+ type: 'number',
1684
+ 'default': 1,
1685
+ min: 0,
1686
+ max: 1,
1687
+ step: 0.05
1688
+ },
1689
+ font: {
1690
+ size: {
1691
+ type: 'quantity',
1692
+ 'default': '.8em',
1693
+ units: [{
1694
+ name: 'em',
1695
+ max: 10,
1696
+ step: 0.01,
1697
+ 'default': 0.8
1698
+ }]
1699
+ }
1700
+ }
1393
1701
  }
1394
1702
  }
1395
1703
  };
1704
+ chart.i18nNs = "@plotdb/chart";
1705
+ chart.i18n = {
1706
+ en: {
1707
+ text: "No data to show"
1708
+ },
1709
+ "zh-TW": {
1710
+ text: "沒有可顯示的資料"
1711
+ },
1712
+ "zh-CN": {
1713
+ text: "没有可显示的数据"
1714
+ },
1715
+ ja: {
1716
+ text: "表示するデータがありません"
1717
+ }
1718
+ };
1396
1719
  chart.scopes = {
1720
+ space: {
1721
+ x: function(v){
1722
+ return null;
1723
+ },
1724
+ y: function(v){
1725
+ return null;
1726
+ }
1727
+ },
1397
1728
  frame: {
1398
1729
  active: function(){
1399
1730
  return !!this._frames;
@@ -4602,6 +4933,10 @@ var chart = module.exports;
4602
4933
  type: 'boolean',
4603
4934
  'default': true
4604
4935
  },
4936
+ actions: {
4937
+ type: 'boolean',
4938
+ 'default': true
4939
+ },
4605
4940
  enabled: {
4606
4941
  type: 'boolean',
4607
4942
  'default': true
@@ -4742,7 +5077,14 @@ var chart = module.exports;
4742
5077
  direction: {
4743
5078
  type: 'choice',
4744
5079
  'default': 'horizontal',
4745
- values: ['horizontal', 'vertical']
5080
+ values: ['horizontal', 'angled', 'vertical', 'auto']
5081
+ },
5082
+ angle: {
5083
+ type: 'number',
5084
+ 'default': 45,
5085
+ min: 0,
5086
+ max: 90,
5087
+ step: 1
4746
5088
  },
4747
5089
  gap: {
4748
5090
  type: 'number',
@@ -5236,7 +5578,7 @@ var chart = module.exports;
5236
5578
  : a.text > b.text ? -1 : 0);
5237
5579
  });
5238
5580
  }
5239
- return ret.concat(this$.cfg.selectable
5581
+ return ret.concat(this$._actions()
5240
5582
  ? this$._func
5241
5583
  : []);
5242
5584
  },
@@ -5267,7 +5609,7 @@ var chart = module.exports;
5267
5609
  handler: {
5268
5610
  legend: {
5269
5611
  list: function(){
5270
- return this$._data.concat(this$.cfg.selectable
5612
+ return this$._data.concat(this$._actions()
5271
5613
  ? this$._func
5272
5614
  : []);
5273
5615
  },
@@ -5384,7 +5726,7 @@ var chart = module.exports;
5384
5726
  this._func.map(function(f){
5385
5727
  return f.text = this$._text(f.key);
5386
5728
  });
5387
- if (!this.cfg.selectable) {
5729
+ if (!this._actions()) {
5388
5730
  return;
5389
5731
  }
5390
5732
  this.view.layout.render('legend');
@@ -5397,6 +5739,9 @@ var chart = module.exports;
5397
5739
  }
5398
5740
  return this._lngHandler = null;
5399
5741
  },
5742
+ _actions: function(){
5743
+ return !!(this.cfg.selectable && (this.cfg.actions != null ? this.cfg.actions : true));
5744
+ },
5400
5745
  _name: function(ctx, type){
5401
5746
  type == null && (type = "s");
5402
5747
  return "pdlg-" + type + "-" + this.id + "-" + (ctx.type || '') + "-" + ctx.key;
@@ -5715,7 +6060,7 @@ var chart = module.exports;
5715
6060
  var map, size, unit, count, itr, ref$, ends, k, v, this$ = this;
5716
6061
  map = {};
5717
6062
  size = this._n.layout.getBoundingClientRect()[this.dir < 2 ? 'width' : 'height'];
5718
- unit = this.dir < 2 && this.cfg.label.direction === 'vertical' ? 12 : 25;
6063
+ unit = this.dir < 2 && this.cfg.label.direction !== 'horizontal' ? 12 : 25;
5719
6064
  count = Math.round(size / unit);
5720
6065
  itr = (ref$ = Math.round(ticks.length / (count > 1 ? count : 1))) > 1 ? ref$ : 1;
5721
6066
  ends = this.cfg.label.strategy === 'ends';
@@ -5858,13 +6203,30 @@ var chart = module.exports;
5858
6203
  return this.adjust();
5859
6204
  },
5860
6205
  adjust: function(){
5861
- var ticks, isHorizon, vertical, em, place, gap, fits, sel, k, i, res$, i$, to$, tol, ref$, lo, hi, pick, even, p, idx, picked, shown, mm3, md3, size, delta, box, xoff, yoff, this$ = this;
6206
+ var ticks, isHorizon, em, gap, fits, place, modes, allIdx, res$, i$, to$, i, len$, mode, sel, k, tol, ref$, lo, hi, pick, even, p, idx, picked, shown, mm3, md3, size, delta, box, xoff, yoff, this$ = this;
5862
6207
  ticks = this._ticks;
5863
6208
  isHorizon = this.dir < 2;
5864
- vertical = isHorizon && this.cfg.label.direction === 'vertical';
5865
6209
  em = parseFloat(getComputedStyle(this._n.wrap).fontSize) || 16;
5866
- place = function(tick, idx){
5867
- var pos, coord, box, offset, doOffset, r, toff;
6210
+ gap = em * (this.cfg.label.gap != null ? this.cfg.label.gap : 1.5);
6211
+ fits = function(idx){
6212
+ var prev, i$, len$, i, tick;
6213
+ prev = null;
6214
+ for (i$ = 0, len$ = idx.length; i$ < len$; ++i$) {
6215
+ i = idx[i$];
6216
+ tick = ticks[i];
6217
+ if (prev != null && tick._start - (prev._start + prev._size) < gap) {
6218
+ return false;
6219
+ }
6220
+ prev = tick;
6221
+ }
6222
+ return true;
6223
+ };
6224
+ place = function(tick, idx, mode){
6225
+ var vertical, angled, ang, ref$, cos, sin, pos, coord, box, offset, doOffset, r, toff;
6226
+ vertical = isHorizon && mode === 'vertical';
6227
+ angled = isHorizon && mode === 'angled';
6228
+ ang = this$.cfg.label.angle != null ? this$.cfg.label.angle : 45;
6229
+ ref$ = [Math.cos(ang * Math.PI / 180), Math.sin(ang * Math.PI / 180)], cos = ref$[0], sin = ref$[1];
5868
6230
  pos = !idx
5869
6231
  ? 0
5870
6232
  : idx === ticks.length - 1 ? 2 : 1;
@@ -5887,6 +6249,8 @@ var chart = module.exports;
5887
6249
  if (vertical) {
5888
6250
  offset.x -= box.width;
5889
6251
  offset.y -= box.height * r;
6252
+ } else if (angled) {
6253
+ offset.x -= box.width;
5890
6254
  } else if (isHorizon) {
5891
6255
  offset.x -= box.width * r;
5892
6256
  } else {
@@ -5895,16 +6259,24 @@ var chart = module.exports;
5895
6259
  tick.n.tt.setAttribute('transform', "translate(" + offset.x + "," + offset.y + ")");
5896
6260
  tick._size = vertical
5897
6261
  ? box.height
5898
- : box[isHorizon ? 'width' : 'height'];
6262
+ : angled
6263
+ ? box.width * cos + box.height * sin
6264
+ : box[isHorizon ? 'width' : 'height'];
5899
6265
  tick._sizeAlt = vertical
5900
6266
  ? box.width
5901
- : box[isHorizon ? 'height' : 'width'];
5902
- tick._start = coord - tick._size * r;
6267
+ : angled
6268
+ ? box.width * sin + box.height * cos
6269
+ : box[isHorizon ? 'height' : 'width'];
6270
+ tick._start = angled
6271
+ ? coord - box.width * cos
6272
+ : coord - tick._size * r;
5903
6273
  if (isHorizon) {
5904
6274
  tick.n.g.setAttribute('transform', "translate(" + coord + ",0)");
5905
6275
  tick.n.p.setAttribute('d', "M0 0L0 " + this$.cfg.tick.inner);
5906
6276
  toff = this$.cfg.tick.inner + this$.cfg.label.padding;
5907
- tick.n.t.setAttribute('transform', ("translate(0," + toff + ")") + (vertical ? " rotate(-90)" : ""));
6277
+ tick.n.t.setAttribute('transform', ("translate(0," + toff + ")") + (vertical
6278
+ ? " rotate(-90)"
6279
+ : angled ? " rotate(" + (-ang) + ")" : ""));
5908
6280
  } else {
5909
6281
  tick.n.g.setAttribute('transform', "translate(0," + coord + ")");
5910
6282
  tick.n.p.setAttribute('d', "M0 0L-" + this$.cfg.tick.inner + " 0");
@@ -5912,26 +6284,27 @@ var chart = module.exports;
5912
6284
  }
5913
6285
  return tick.n.p.style.stroke = this$.cfg.tick.color || '';
5914
6286
  };
5915
- ticks.map(place);
5916
- gap = em * (this.cfg.label.gap != null ? this.cfg.label.gap : 1.5);
5917
- fits = function(idx){
5918
- var prev, i$, len$, i, tick;
5919
- prev = null;
5920
- for (i$ = 0, len$ = idx.length; i$ < len$; ++i$) {
5921
- i = idx[i$];
5922
- tick = ticks[i];
5923
- if (prev != null && tick._start - (prev._start + prev._size) < gap) {
5924
- return false;
5925
- }
5926
- prev = tick;
6287
+ modes = isHorizon && this.cfg.label.direction === 'auto'
6288
+ ? ['horizontal', 'angled', 'vertical']
6289
+ : [this.cfg.label.direction || 'horizontal'];
6290
+ res$ = [];
6291
+ for (i$ = 0, to$ = ticks.length; i$ < to$; ++i$) {
6292
+ i = i$;
6293
+ res$.push(i);
6294
+ }
6295
+ allIdx = res$;
6296
+ for (i$ = 0, len$ = modes.length; i$ < len$; ++i$) {
6297
+ mode = modes[i$];
6298
+ ticks.map(fn$);
6299
+ if (fits(allIdx)) {
6300
+ break;
5927
6301
  }
5928
- return true;
5929
- };
6302
+ }
5930
6303
  sel = [0];
5931
6304
  if (ticks.length > 1) {
5932
6305
  if (this.cfg.label.strategy !== 'ends') {
5933
6306
  k = 1;
5934
- while (k < ticks.length && !fits((fn$()))) {
6307
+ while (k < ticks.length && !fits((fn1$()))) {
5935
6308
  k++;
5936
6309
  }
5937
6310
  res$ = [];
@@ -6050,7 +6423,10 @@ var chart = module.exports;
6050
6423
  return n.setAttribute('transform', "translate(" + xoff + "," + yoff + ") rotate(90)");
6051
6424
  });
6052
6425
  }
6053
- function fn$(){
6426
+ function fn$(tick, i){
6427
+ return place(tick, i, mode);
6428
+ }
6429
+ function fn1$(){
6054
6430
  var i$, step$, to$, results$ = [];
6055
6431
  for (i$ = 0, to$ = ticks.length, step$ = k; step$ < 0 ? i$ > to$ : i$ < to$; i$ += step$) {
6056
6432
  i = i$;