chartkick 2.3.4 → 2.3.5
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.
Potentially problematic release.
This version of chartkick might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/README.md +8 -0
- data/lib/chartkick/version.rb +1 -1
- data/vendor/assets/javascripts/chartkick.js +62 -18
- metadata +2 -2
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA256:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: d37a995b1d870a7e93be5d5eb338d163e1b42653304baab7bad889aff6f655fe
         | 
| 4 | 
            +
              data.tar.gz: 9c5495a74d4e6c03b199a263556d9dcee91ee4e0c87fb7694851971068a817e2
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: e2e350cf8f342a7d55bfbc0a6581c92e25b4a59442719ef12aa32400ba9610b137360a10535a96afa049025a739235f28b00ade4299ad1cad5d2f9525ea1517d
         | 
| 7 | 
            +
              data.tar.gz: 3de86761cb1f9e63d71589640827cc8391c668b398f9e49cdf4f4029351850181cc4e8197d8c6c341b6e7d79147ee01d96be6cf72b55ccca1f1395f4504d951e
         | 
    
        data/CHANGELOG.md
    CHANGED
    
    
    
        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:
         | 
    
        data/lib/chartkick/version.rb
    CHANGED
    
    
| @@ -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 | 
            +
             * 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 | 
            -
                   | 
| 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. | 
| 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. | 
| 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. | 
| 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. | 
| 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 | 
            -
                   | 
| 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. | 
| 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 | 
            +
              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- | 
| 11 | 
            +
            date: 2018-06-15 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: bundler
         |