chartkick 3.3.1 → 3.3.2

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: 3d2deed8ea6acea7a2d4e68d7a0adfb2a396ff685ddd4763a6e7dc7cc9f981b5
4
- data.tar.gz: 8c1502d6b8a5b2feda3727c23d0a39e14c1c667b4bc3856f3f106e662490517d
3
+ metadata.gz: b462bf7fa745700c8fa561b0e5707c309f6f5cca29e314e550921370b3a9d590
4
+ data.tar.gz: be9169ad2777d6e40846ef058ad981a3366aea965f16aa2e1af44d7c2b81cad4
5
5
  SHA512:
6
- metadata.gz: 6b662ba0dea0a3c8e116fa6428bc52bd4288a301d20395f9671a3e478199c30278db020043c534f2edd62f0971fb5a7f4fa3608136d23b40103930afa59032d2
7
- data.tar.gz: 78d2f5473da5ce6b60a68eea76bb848339f4a77981595d9bc693e6e2fd83f9010f2ce6628570c7d034140e2c1416eda246d85fcae533a7d177d3ab4ef01e8281
6
+ metadata.gz: 2eedfd5f334b4e875d88b7b5e9af963a8ad3c4f8fc86eb17b31f0fb41e3b357cb3909a27cc92f8018c709856f56a7c0614ec95ac5ab8747549767e1f95fd7de8
7
+ data.tar.gz: f997c95810273ed9d436f3e307b92b3936fe17736d01adda4979efc90379f45a703d97aeeed3c9a3add187440d0d085c8b3e4635df2dec0720491c9268a80eda
@@ -1,3 +1,7 @@
1
+ ## 3.3.2 (2020-07-23)
2
+
3
+ - Updated Chartkick.js to 3.2.1
4
+
1
5
  ## 3.3.1 (2019-12-26)
2
6
 
3
7
  - Updated Chart.js to 2.9.3
data/README.md CHANGED
@@ -8,6 +8,8 @@ Create beautiful JavaScript charts with one line of Ruby. No more fighting with
8
8
 
9
9
  :two_hearts: A perfect companion to [Groupdate](https://github.com/ankane/groupdate), [Hightop](https://github.com/ankane/hightop), and [ActiveMedian](https://github.com/ankane/active_median)
10
10
 
11
+ [![Build Status](https://travis-ci.org/ankane/chartkick.svg?branch=master)](https://travis-ci.org/ankane/chartkick)
12
+
11
13
  ## Quick Start
12
14
 
13
15
  Add this line to your application's Gemfile:
@@ -323,7 +325,7 @@ Then, in your layout, use:
323
325
  <%= yield :charts_js %>
324
326
  ```
325
327
 
326
- > For Padrino, use `yield_content` instead of `yield`
328
+ For Padrino, use `yield_content` instead of `yield`.
327
329
 
328
330
  This is great for including all of your JavaScript at the bottom of the page.
329
331
 
@@ -370,9 +372,7 @@ If you want to use the charting library directly, get the code with:
370
372
  <%= line_chart data, code: true %>
371
373
  ```
372
374
 
373
- The code will be logged to the JavaScript console.
374
-
375
- > JavaScript functions cannot be logged, so it may not be identical.
375
+ The code will be logged to the JavaScript console. JavaScript functions cannot be logged, so it may not be identical.
376
376
 
377
377
  ### Download Charts
378
378
 
@@ -384,7 +384,7 @@ Give users the ability to download charts. It all happens in the browser - no se
384
384
  <%= line_chart data, download: true %>
385
385
  ```
386
386
 
387
- > Safari will open the image in a new window instead of downloading.
387
+ Safari will open the image in a new window instead of downloading.
388
388
 
389
389
  Set the filename
390
390
 
@@ -418,7 +418,7 @@ Next, choose your charting library.
418
418
  - [Google Charts](#google-charts)
419
419
  - [Highcharts](#highcharts)
420
420
 
421
- > In the instructions below, `application.js` must be included **before** the charts in your views, unless using the `:content_for` option.
421
+ In the instructions below, `application.js` must be included **before** the charts in your views, unless using the `:content_for` option.
422
422
 
423
423
  ### Chart.js
424
424
 
@@ -562,6 +562,12 @@ Redraw the chart with:
562
562
  chart.redraw()
563
563
  ```
564
564
 
565
+ Destroy the chart with:
566
+
567
+ ```javascript
568
+ chart.destroy()
569
+ ```
570
+
565
571
  Loop over charts with:
566
572
 
567
573
  ```javascript
@@ -597,14 +603,6 @@ Breaking changes
597
603
  - Removed `window.Chartkick = {...}` way to set config - use `Chartkick.configure` instead
598
604
  - Removed support for the Google Charts jsapi loader - use loader.js instead
599
605
 
600
- ### 2.0
601
-
602
- Breaking changes
603
-
604
- - Chart.js is now the default adapter if multiple are loaded - yay open source!
605
- - Axis types are automatically detected - no need for `discrete: true`
606
- - Better date support - dates are no longer treated as UTC
607
-
608
606
  ## Credits
609
607
 
610
608
  Chartkick uses [iso8601.js](https://github.com/Do/iso8601.js) to parse dates and times.
@@ -613,8 +611,6 @@ Chartkick uses [iso8601.js](https://github.com/Do/iso8601.js) to parse dates and
613
611
 
614
612
  View the [changelog](https://github.com/ankane/chartkick/blob/master/CHANGELOG.md)
615
613
 
616
- Chartkick follows [Semantic Versioning](https://semver.org/)
617
-
618
614
  ## Contributing
619
615
 
620
616
  Everyone is encouraged to help improve this project. Here are a few ways you can help:
@@ -623,3 +619,12 @@ Everyone is encouraged to help improve this project. Here are a few ways you can
623
619
  - Fix bugs and [submit pull requests](https://github.com/ankane/chartkick/pulls)
624
620
  - Write, clarify, or fix documentation
625
621
  - Suggest or add new features
622
+
623
+ To get started with development:
624
+
625
+ ```sh
626
+ git clone https://github.com/ankane/chartkick.git
627
+ cd chartkick
628
+ bundle install
629
+ bundle exec rake test
630
+ ```
@@ -85,6 +85,7 @@ module Chartkick
85
85
  createjs = "new Chartkick[%{type}](%{id}, %{data}, %{options});" % js_vars
86
86
 
87
87
  if defer
88
+ # TODO remove type in 4.0
88
89
  js = <<JS
89
90
  <script type="text/javascript"#{nonce_html}>
90
91
  (function() {
@@ -100,6 +101,7 @@ module Chartkick
100
101
  </script>
101
102
  JS
102
103
  else
104
+ # TODO remove type in 4.0
103
105
  js = <<JS
104
106
  <script type="text/javascript"#{nonce_html}>
105
107
  #{createjs}
@@ -1,3 +1,3 @@
1
1
  module Chartkick
2
- VERSION = "3.3.1"
2
+ VERSION = "3.3.2"
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
- * v3.2.0
5
+ * v3.2.1
6
6
  * MIT License
7
7
  */
8
8
 
@@ -241,6 +241,8 @@
241
241
  return typeof obj === "number";
242
242
  }
243
243
 
244
+ var byteSuffixes = ["bytes", "KB", "MB", "GB", "TB", "PB", "EB"];
245
+
244
246
  function formatValue(pre, value, options, axis) {
245
247
  pre = pre || "";
246
248
  if (options.prefix) {
@@ -256,26 +258,42 @@
256
258
  var round = options.round;
257
259
 
258
260
  if (options.byteScale) {
261
+ var suffixIdx;
259
262
  var baseValue = axis ? options.byteScale : value;
260
- if (baseValue >= 1099511627776) {
263
+
264
+ if (baseValue >= 1152921504606846976) {
265
+ value /= 1152921504606846976;
266
+ suffixIdx = 6;
267
+ } else if (baseValue >= 1125899906842624) {
268
+ value /= 1125899906842624;
269
+ suffixIdx = 5;
270
+ } else if (baseValue >= 1099511627776) {
261
271
  value /= 1099511627776;
262
- suffix = " TB";
272
+ suffixIdx = 4;
263
273
  } else if (baseValue >= 1073741824) {
264
274
  value /= 1073741824;
265
- suffix = " GB";
275
+ suffixIdx = 3;
266
276
  } else if (baseValue >= 1048576) {
267
277
  value /= 1048576;
268
- suffix = " MB";
278
+ suffixIdx = 2;
269
279
  } else if (baseValue >= 1024) {
270
280
  value /= 1024;
271
- suffix = " KB";
281
+ suffixIdx = 1;
272
282
  } else {
273
- suffix = " bytes";
283
+ suffixIdx = 0;
274
284
  }
275
285
 
286
+ // TODO handle manual precision case
276
287
  if (precision === undefined && round === undefined) {
277
- precision = 3;
288
+ if (value >= 1023.5) {
289
+ if (suffixIdx < byteSuffixes.length - 1) {
290
+ value = 1.0;
291
+ suffixIdx += 1;
292
+ }
293
+ }
294
+ precision = value >= 1000 ? 4 : 3;
278
295
  }
296
+ suffix = " " + byteSuffixes[suffixIdx];
279
297
  }
280
298
 
281
299
  if (precision !== undefined && round !== undefined) {
@@ -746,6 +764,22 @@
746
764
  }
747
765
  }
748
766
 
767
+ // for empty datetime chart
768
+ if (chart.xtype === "datetime" && labels.length === 0) {
769
+ if (notnull(xmin)) {
770
+ labels.push(toDate(xmin));
771
+ }
772
+ if (notnull(xmax)) {
773
+ labels.push(toDate(xmax));
774
+ }
775
+ day = false;
776
+ week = false;
777
+ month = false;
778
+ year = false;
779
+ hour = false;
780
+ minute = false;
781
+ }
782
+
749
783
  if (chart.xtype === "datetime" && labels.length > 0) {
750
784
  var minTime = (notnull(xmin) ? toDate(xmin) : labels[0]).getTime();
751
785
  var maxTime = (notnull(xmax) ? toDate(xmax) : labels[0]).getTime();
@@ -1448,7 +1482,7 @@
1448
1482
  defaultExport$2.prototype.renderGeoChart = function renderGeoChart (chart) {
1449
1483
  var this$1 = this;
1450
1484
 
1451
- this.waitForLoaded(chart, function () {
1485
+ this.waitForLoaded(chart, "geochart", function () {
1452
1486
  var chartOptions = {
1453
1487
  legend: "none",
1454
1488
  colorAxis: {
@@ -1564,7 +1598,7 @@
1564
1598
  if (config.language) {
1565
1599
  loadOptions.language = config.language;
1566
1600
  }
1567
- if (pack === "corechart" && config.mapsApiKey) {
1601
+ if (pack === "geochart" && config.mapsApiKey) {
1568
1602
  loadOptions.mapsApiKey = config.mapsApiKey;
1569
1603
  }
1570
1604
 
@@ -1576,7 +1610,7 @@
1576
1610
  var cb, call;
1577
1611
  for (var i = 0; i < callbacks.length; i++) {
1578
1612
  cb = callbacks[i];
1579
- call = this.library.visualization && ((cb.pack === "corechart" && this.library.visualization.LineChart) || (cb.pack === "timeline" && this.library.visualization.Timeline));
1613
+ call = this.library.visualization && ((cb.pack === "corechart" && this.library.visualization.LineChart) || (cb.pack === "timeline" && this.library.visualization.Timeline) || (cb.pack === "geochart" && this.library.visualization.GeoChart));
1580
1614
  if (call) {
1581
1615
  cb.callback();
1582
1616
  callbacks.splice(i, 1);
@@ -1951,8 +1985,14 @@
1951
1985
  return r;
1952
1986
  };
1953
1987
 
1954
- function detectXType(series, noDatetime) {
1955
- if (detectXTypeWithFunction(series, isNumber)) {
1988
+ function detectXType(series, noDatetime, options) {
1989
+ if (dataEmpty(series)) {
1990
+ if ((options.xmin || options.xmax) && (!options.xmin || isDate(options.xmin)) && (!options.xmax || isDate(options.xmax))) {
1991
+ return "datetime";
1992
+ } else {
1993
+ return "number";
1994
+ }
1995
+ } else if (detectXTypeWithFunction(series, isNumber)) {
1956
1996
  return "number";
1957
1997
  } else if (!noDatetime && detectXTypeWithFunction(series, isDate)) {
1958
1998
  return "datetime";
@@ -2004,12 +2044,18 @@
2004
2044
  chart.hideLegend = false;
2005
2045
  }
2006
2046
 
2007
- chart.xtype = keyType ? keyType : (opts.discrete ? "string" : detectXType(series, noDatetime));
2047
+ // convert to array
2048
+ // must come before dataEmpty check
2049
+ series = copySeries(series);
2050
+ for (i = 0; i < series.length; i++) {
2051
+ series[i].data = toArr(series[i].data);
2052
+ }
2053
+
2054
+ chart.xtype = keyType ? keyType : (opts.discrete ? "string" : detectXType(series, noDatetime, opts));
2008
2055
 
2009
2056
  // right format
2010
- series = copySeries(series);
2011
2057
  for (i = 0; i < series.length; i++) {
2012
- series[i].data = formatSeriesData(toArr(series[i].data), chart.xtype);
2058
+ series[i].data = formatSeriesData(series[i].data, chart.xtype);
2013
2059
  }
2014
2060
 
2015
2061
  return series;
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: 3.3.1
4
+ version: 3.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Kane
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-12-27 00:00:00.000000000 Z
11
+ date: 2020-07-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -59,7 +59,6 @@ extensions: []
59
59
  extra_rdoc_files: []
60
60
  files:
61
61
  - CHANGELOG.md
62
- - CONTRIBUTING.md
63
62
  - LICENSE.txt
64
63
  - README.md
65
64
  - lib/chartkick.rb
@@ -1,46 +0,0 @@
1
- # Contributing
2
-
3
- First, thanks for wanting to contribute. You’re awesome! :heart:
4
-
5
- ## Help
6
-
7
- We’re not able to provide support through GitHub Issues. If you’re looking for help with your code, try posting on [Stack Overflow](https://stackoverflow.com/).
8
-
9
- All features should be documented. If you don’t see a feature in the docs, assume it doesn’t exist.
10
-
11
- ## Bugs
12
-
13
- Think you’ve discovered a bug?
14
-
15
- 1. Search existing issues to see if it’s been reported.
16
- 2. Try the `master` branch to make sure it hasn’t been fixed.
17
-
18
- ```rb
19
- gem "chartkick", github: "ankane/chartkick"
20
- ```
21
-
22
- If the above steps don’t help, create an issue. Include:
23
-
24
- - Detailed steps to reproduce
25
- - JavaScript rendered by Chartkick
26
- - Complete backtraces for exceptions
27
-
28
- ## New Features
29
-
30
- If you’d like to discuss a new feature, create an issue and start the title with `[Idea]`.
31
-
32
- ## Pull Requests
33
-
34
- Fork the project and create a pull request. A few tips:
35
-
36
- - Submit JavaScript changes to the [Chartkick.js](https://github.com/ankane/chartkick.js) repo.
37
- - Keep changes to a minimum. If you have multiple features or fixes, submit multiple pull requests.
38
- - Follow the existing style. The code should read like it’s written by a single person.
39
-
40
- Feel free to open an issue to get feedback on your idea before spending too much time on it.
41
-
42
- Also, note that we aren’t currently accepting new chart types.
43
-
44
- ---
45
-
46
- This contributing guide is released under [CCO](https://creativecommons.org/publicdomain/zero/1.0/) (public domain). Use it for your own project without attribution.