chartkick 2.3.4 → 2.3.5

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of chartkick might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6d951f0a4aa01b326035d2d0450b52ecdab42394db007f491961da275e07ed3b
4
- data.tar.gz: b00f3adb59f0dea93aebcdbaa7e46c5489dfc3880ee173a7fb092378fd380f0a
3
+ metadata.gz: d37a995b1d870a7e93be5d5eb338d163e1b42653304baab7bad889aff6f655fe
4
+ data.tar.gz: 9c5495a74d4e6c03b199a263556d9dcee91ee4e0c87fb7694851971068a817e2
5
5
  SHA512:
6
- metadata.gz: 1ac7c061e06073552822ba3109b85551e7a3461e9eb605af414da45b57b134842ff328832a8610038a5a4dd6d6180e2d50a21083d35374bd6da3664c69a485e5
7
- data.tar.gz: bdc7c87d2cc57f534c4f2d200e0b8bcaec5e891e4d778461079e1129f6df53b5df283685a0934ec4e87e8e71154c19a3b8fea052fb0152ffdd91ec064f050b07
6
+ metadata.gz: e2e350cf8f342a7d55bfbc0a6581c92e25b4a59442719ef12aa32400ba9610b137360a10535a96afa049025a739235f28b00ade4299ad1cad5d2f9525ea1517d
7
+ data.tar.gz: 3de86761cb1f9e63d71589640827cc8391c668b398f9e49cdf4f4029351850181cc4e8197d8c6c341b6e7d79147ee01d96be6cf72b55ccca1f1395f4504d951e
@@ -1,3 +1,7 @@
1
+ ## 2.3.5
2
+
3
+ - Updated Chartkick.js to 2.3.6
4
+
1
5
  ## 2.3.4
2
6
 
3
7
  - Updated Chartkick.js to 2.3.5
data/README.md CHANGED
@@ -226,6 +226,14 @@ You can pass options directly to the charting library with:
226
226
 
227
227
  See the documentation for [Chart.js](https://www.chartjs.org/docs/), [Google Charts](https://developers.google.com/chart/interactive/docs/gallery), and [Highcharts](https://api.highcharts.com/highcharts) for more info.
228
228
 
229
+ To customize datasets in Chart.js, use:
230
+
231
+ ```erb
232
+ <%= line_chart data, dataset: {borderWidth: 10} %>
233
+ ```
234
+
235
+ You can pass this option to individual series as well.
236
+
229
237
  ### Global Options
230
238
 
231
239
  To set options for all of your charts, create an initializer `config/initializers/chartkick.rb` with:
@@ -1,3 +1,3 @@
1
1
  module Chartkick
2
- VERSION = "2.3.4"
2
+ VERSION = "2.3.5"
3
3
  end
@@ -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
- * v2.3.5
5
+ * v2.3.6
6
6
  * MIT License
7
7
  */
8
8
 
@@ -532,6 +532,7 @@
532
532
  borderColor: color,
533
533
  backgroundColor: backgroundColor,
534
534
  pointBackgroundColor: color,
535
+ pointHoverBackgroundColor: color,
535
536
  borderWidth: 2
536
537
  };
537
538
 
@@ -548,7 +549,11 @@
548
549
  dataset.pointHitRadius = 5;
549
550
  }
550
551
 
551
- datasets.push(merge(dataset, s.library || {}));
552
+ dataset = merge(dataset, chart.options.dataset || {});
553
+ dataset = merge(dataset, s.library || {});
554
+ dataset = merge(dataset, s.dataset || {});
555
+
556
+ datasets.push(dataset);
552
557
  }
553
558
 
554
559
  if (detectType && labels.length > 0) {
@@ -666,14 +671,15 @@
666
671
  values.push(point[1]);
667
672
  }
668
673
 
674
+ var dataset = {
675
+ data: values,
676
+ backgroundColor: chart.options.colors || defaultColors
677
+ };
678
+ dataset = merge(dataset, chart.options.dataset || {});
679
+
669
680
  var data = {
670
681
  labels: labels,
671
- datasets: [
672
- {
673
- data: values,
674
- backgroundColor: chart.options.colors || defaultColors
675
- }
676
- ]
682
+ datasets: [dataset]
677
683
  };
678
684
 
679
685
  this.drawChart(chart, "pie", data, options);
@@ -758,10 +764,14 @@
758
764
  this.renderScatterChart(chart, "bubble");
759
765
  };
760
766
 
761
- defaultExport.prototype.drawChart = function drawChart (chart, type, data, options) {
767
+ defaultExport.prototype.destroy = function destroy (chart) {
762
768
  if (chart.chart) {
763
769
  chart.chart.destroy();
764
770
  }
771
+ };
772
+
773
+ defaultExport.prototype.drawChart = function drawChart (chart, type, data, options) {
774
+ this.destroy(chart);
765
775
 
766
776
  chart.element.innerHTML = "<canvas></canvas>";
767
777
  var ctx = chart.element.getElementsByTagName("CANVAS")[0];
@@ -1030,10 +1040,14 @@
1030
1040
  this.renderLineChart(chart, "areaspline");
1031
1041
  };
1032
1042
 
1033
- defaultExport$1.prototype.drawChart = function drawChart (chart, data, options) {
1043
+ defaultExport$1.prototype.destroy = function destroy (chart) {
1034
1044
  if (chart.chart) {
1035
1045
  chart.chart.destroy();
1036
1046
  }
1047
+ };
1048
+
1049
+ defaultExport$1.prototype.drawChart = function drawChart (chart, data, options) {
1050
+ this.destroy(chart);
1037
1051
 
1038
1052
  options.chart.renderTo = chart.element.id;
1039
1053
  options.series = data;
@@ -1337,10 +1351,14 @@
1337
1351
  });
1338
1352
  };
1339
1353
 
1340
- defaultExport$2.prototype.drawChart = function drawChart (chart, type, data, options) {
1354
+ defaultExport$2.prototype.destroy = function destroy (chart) {
1341
1355
  if (chart.chart) {
1342
1356
  chart.chart.clearChart();
1343
1357
  }
1358
+ };
1359
+
1360
+ defaultExport$2.prototype.drawChart = function drawChart (chart, type, data, options) {
1361
+ this.destroy(chart);
1344
1362
 
1345
1363
  chart.chart = new type(chart.element);
1346
1364
  resize(function () {
@@ -1574,20 +1592,20 @@
1574
1592
  link.appendChild(image);
1575
1593
  element.style.position = "relative";
1576
1594
 
1577
- chart.downloadAttached = true;
1595
+ chart.__downloadAttached = true;
1578
1596
 
1579
1597
  // mouseenter
1580
- addEvent(element, "mouseover", function(e) {
1598
+ chart.__enterEvent = addEvent(element, "mouseover", function(e) {
1581
1599
  var related = e.relatedTarget;
1582
1600
  // check download option again to ensure it wasn't changed
1583
- if (!related || (related !== this && !childOf(this, related)) && chart.options.download) {
1601
+ if ((!related || (related !== this && !childOf(this, related))) && chart.options.download) {
1584
1602
  link.href = chart.toImage();
1585
1603
  element.appendChild(link);
1586
1604
  }
1587
1605
  });
1588
1606
 
1589
1607
  // mouseleave
1590
- addEvent(element, "mouseout", function(e) {
1608
+ chart.__leaveEvent = addEvent(element, "mouseout", function(e) {
1591
1609
  var related = e.relatedTarget;
1592
1610
  if (!related || (related !== this && !childOf(this, related))) {
1593
1611
  if (link.parentNode) {
@@ -1601,11 +1619,22 @@
1601
1619
  function addEvent(elem, event, fn) {
1602
1620
  if (elem.addEventListener) {
1603
1621
  elem.addEventListener(event, fn, false);
1622
+ return fn;
1604
1623
  } else {
1605
- elem.attachEvent("on" + event, function() {
1624
+ var fn2 = function() {
1606
1625
  // set the this pointer same as addEventListener when fn is called
1607
1626
  return(fn.call(elem, window.event));
1608
- });
1627
+ };
1628
+ elem.attachEvent("on" + event, fn2);
1629
+ return fn2;
1630
+ }
1631
+ }
1632
+
1633
+ function removeEvent(elem, event, fn) {
1634
+ if (elem.removeEventListener) {
1635
+ elem.removeEventListener(event, fn, false);
1636
+ } else {
1637
+ elem.detachEvent("on" + event, fn);
1609
1638
  }
1610
1639
  }
1611
1640
 
@@ -1670,7 +1699,7 @@
1670
1699
  setText(chart.element, chart.options.messages.empty);
1671
1700
  } else {
1672
1701
  callAdapter(chartType, chart);
1673
- if (chart.options.download && !chart.downloadAttached && chart.adapter === "chartjs") {
1702
+ if (chart.options.download && !chart.__downloadAttached && chart.adapter === "chartjs") {
1674
1703
  addDownloadButton(chart);
1675
1704
  }
1676
1705
  }
@@ -1689,6 +1718,7 @@
1689
1718
  adapter = adapters[i];
1690
1719
  if ((!adapterName || adapterName === adapter.name) && isFunction(adapter[fnName])) {
1691
1720
  chart.adapter = adapter.name;
1721
+ chart.__adapterObject = adapter;
1692
1722
  return adapter[fnName](chart);
1693
1723
  }
1694
1724
  }
@@ -1907,6 +1937,20 @@
1907
1937
  }
1908
1938
  };
1909
1939
 
1940
+ Chart.prototype.destroy = function destroy () {
1941
+ if (this.__adapterObject) {
1942
+ this.__adapterObject.destroy(this);
1943
+ }
1944
+
1945
+ if (this.__enterEvent) {
1946
+ removeEvent(this.element, "mouseover", this.__enterEvent);
1947
+ }
1948
+
1949
+ if (this.__leaveEvent) {
1950
+ removeEvent(this.element, "mouseout", this.__leaveEvent);
1951
+ }
1952
+ };
1953
+
1910
1954
  Chart.prototype.__updateOptions = function __updateOptions (options) {
1911
1955
  var updateRefresh = options.refresh && options.refresh !== this.options.refresh;
1912
1956
  this.options = merge(Chartkick.options, options);
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: 2.3.4
4
+ version: 2.3.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Kane
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-04-10 00:00:00.000000000 Z
11
+ date: 2018-06-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler