chartkick 4.0.3 → 4.0.4

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.
@@ -2,7 +2,7 @@
2
2
  * Chartkick.js
3
3
  * Create beautiful charts with one line of JavaScript
4
4
  * https://github.com/ankane/chartkick.js
5
- * v4.0.3
5
+ * v4.0.4
6
6
  * MIT License
7
7
  */
8
8
 
@@ -816,11 +816,15 @@
816
816
  }
817
817
 
818
818
  if (step && timeDiff > 0) {
819
- var unitStepSize = Math.ceil(timeDiff / step / (chart.element.offsetWidth / 100.0));
820
- if (week && step === 1) {
821
- unitStepSize = Math.ceil(unitStepSize / 7.0) * 7;
819
+ // width not available for hidden elements
820
+ var width = chart.element.offsetWidth;
821
+ if (width > 0) {
822
+ var unitStepSize = Math.ceil(timeDiff / step / (width / 100.0));
823
+ if (week && step === 1) {
824
+ unitStepSize = Math.ceil(unitStepSize / 7.0) * 7;
825
+ }
826
+ options.scales.x.time.stepSize = unitStepSize;
822
827
  }
823
- options.scales.x.time.stepSize = unitStepSize;
824
828
  }
825
829
  }
826
830
 
@@ -1721,6 +1725,7 @@
1721
1725
 
1722
1726
  return r;
1723
1727
  }
1728
+
1724
1729
  function detectXType(series, noDatetime, options) {
1725
1730
  if (dataEmpty(series)) {
1726
1731
  if ((options.xmin || options.xmax) && (!options.xmin || isDate(options.xmin)) && (!options.xmax || isDate(options.xmax))) {
@@ -1881,6 +1886,14 @@
1881
1886
  }
1882
1887
  }
1883
1888
 
1889
+ function removeEvent(elem, event, fn) {
1890
+ if (elem.removeEventListener) {
1891
+ elem.removeEventListener(event, fn, false);
1892
+ } else {
1893
+ elem.detachEvent("on" + event, fn);
1894
+ }
1895
+ }
1896
+
1884
1897
  // https://gist.github.com/shawnbot/4166283
1885
1898
  function childOf(p, c) {
1886
1899
  if (p === c) { return false; }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chartkick
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.3
4
+ version: 4.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Kane
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-04-11 00:00:00.000000000 Z
11
+ date: 2021-05-01 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description:
14
14
  email: andrew@ankane.org