chartkick 5.0.0 → 5.0.1
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -1
- data/README.md +5 -5
- data/lib/chartkick/version.rb +1 -1
- data/vendor/assets/javascripts/chartkick.js +48 -16
- 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: 9ac4b71bb9edbf35b307e350adf2fc5ebfed0e23618ca5e079f37e3ce548f68c
|
4
|
+
data.tar.gz: b5a6a2499a5e9835d3dcc7b002a881d60d85a66efc45c79931cc9897cdeca6de
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 709e242eff3d7c82c2c78dee8f0693f055819e3a0e24db1d5d58fe4d3564d1309a2477d45fc2b261685a6d60f81d6a2b6ace5a7c03dce48db1fea4cdb7bce4ae
|
7
|
+
data.tar.gz: c866cf49a27a03a16fdaa276b5b002b5eb36378b8f16ce062a3d2a08a56c67b47d286035f5e47cea8bf549e33174d6581a0024f4c8e96ca32849ef236c91e24d
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -22,10 +22,10 @@ gem "chartkick"
|
|
22
22
|
|
23
23
|
Then follow the instructions for your JavaScript setup:
|
24
24
|
|
25
|
-
- [Importmap](#
|
26
|
-
- [esbuild, rollup.js, or Webpack](#
|
27
|
-
- [Webpacker](#
|
28
|
-
- [Sprockets](#
|
25
|
+
- [Importmap](#importmap) (Rails 7 default)
|
26
|
+
- [esbuild, rollup.js, or Webpack](#esbuild-rollupjs-or-webpack)
|
27
|
+
- [Webpacker](#webpacker) (Rails 6 default)
|
28
|
+
- [Sprockets](#sprockets)
|
29
29
|
|
30
30
|
This sets up Chartkick with [Chart.js](https://www.chartjs.org/). For other charting libraries and frameworks, see [detailed instructions](#installation).
|
31
31
|
|
@@ -588,7 +588,7 @@ Download [chartkick.js](https://raw.githubusercontent.com/ankane/chartkick/maste
|
|
588
588
|
|
589
589
|
Then include the charting library.
|
590
590
|
|
591
|
-
Chart.js - download [Chart.js](https://unpkg.com/chart.js@
|
591
|
+
Chart.js - download [Chart.js](https://unpkg.com/chart.js@4/dist/chart.umd.js) and the [date-fns adapter bundle](https://unpkg.com/chartjs-adapter-date-fns@3/dist/chartjs-adapter-date-fns.bundle.js)
|
592
592
|
|
593
593
|
```html
|
594
594
|
<script src="chart.js"></script>
|
data/lib/chartkick/version.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
/*!
|
2
|
-
* Chartkick.js v5.0.
|
2
|
+
* Chartkick.js v5.0.1
|
3
3
|
* Create beautiful charts with one line of JavaScript
|
4
4
|
* https://github.com/ankane/chartkick.js
|
5
5
|
* MIT License
|
@@ -211,15 +211,11 @@
|
|
211
211
|
return "day";
|
212
212
|
}
|
213
213
|
|
214
|
-
var dayOfWeek = values[0].getDay();
|
215
|
-
var week = every(values, function (d) { return d.getDay() === dayOfWeek; });
|
216
|
-
if (!week) {
|
217
|
-
return "day";
|
218
|
-
}
|
219
|
-
|
220
214
|
var month = every(values, function (d) { return d.getDate() === 1; });
|
221
215
|
if (!month) {
|
222
|
-
|
216
|
+
var dayOfWeek = values[0].getDay();
|
217
|
+
var week = every(values, function (d) { return d.getDay() === dayOfWeek; });
|
218
|
+
return (week ? "week" : "day");
|
223
219
|
}
|
224
220
|
|
225
221
|
var year = every(values, function (d) { return d.getMonth() === 0; });
|
@@ -499,15 +495,20 @@
|
|
499
495
|
}
|
500
496
|
|
501
497
|
function setFormatOptions$1(chart, options, chartType) {
|
502
|
-
|
498
|
+
// options to apply to x and r values for scatter and bubble
|
499
|
+
var numericOptions = {
|
500
|
+
thousands: chart.options.thousands,
|
501
|
+
decimal: chart.options.decimal
|
502
|
+
};
|
503
|
+
|
504
|
+
// options to apply to y value
|
505
|
+
var formatOptions = merge({
|
503
506
|
prefix: chart.options.prefix,
|
504
507
|
suffix: chart.options.suffix,
|
505
|
-
thousands: chart.options.thousands,
|
506
|
-
decimal: chart.options.decimal,
|
507
508
|
precision: chart.options.precision,
|
508
509
|
round: chart.options.round,
|
509
510
|
zeros: chart.options.zeros
|
510
|
-
};
|
511
|
+
}, numericOptions);
|
511
512
|
|
512
513
|
if (chart.options.bytes) {
|
513
514
|
var series = chart.data;
|
@@ -539,6 +540,12 @@
|
|
539
540
|
return formatValue("", value, formatOptions, true);
|
540
541
|
};
|
541
542
|
}
|
543
|
+
|
544
|
+
if ((chartType === "scatter" || chartType === "bubble") && !options.scales.x.ticks.callback) {
|
545
|
+
options.scales.x.ticks.callback = function (value) {
|
546
|
+
return formatValue("", value, numericOptions, true);
|
547
|
+
};
|
548
|
+
}
|
542
549
|
}
|
543
550
|
|
544
551
|
if (!options.plugins.tooltip.callbacks.label) {
|
@@ -549,7 +556,8 @@
|
|
549
556
|
label += ': ';
|
550
557
|
}
|
551
558
|
|
552
|
-
|
559
|
+
var dataPoint = context.parsed;
|
560
|
+
return label + '(' + formatValue('', dataPoint.x, numericOptions) + ', ' + formatValue('', dataPoint.y, formatOptions) + ')';
|
553
561
|
};
|
554
562
|
} else if (chartType === "bubble") {
|
555
563
|
options.plugins.tooltip.callbacks.label = function (context) {
|
@@ -558,7 +566,7 @@
|
|
558
566
|
label += ': ';
|
559
567
|
}
|
560
568
|
var dataPoint = context.raw;
|
561
|
-
return label + '(' + dataPoint.x + ', ' + dataPoint.y + ', ' + dataPoint.v + ')';
|
569
|
+
return label + '(' + formatValue('', dataPoint.x, numericOptions) + ', ' + formatValue('', dataPoint.y, formatOptions) + ', ' + formatValue('', dataPoint.v, numericOptions) + ')';
|
562
570
|
};
|
563
571
|
} else if (chartType === "pie") {
|
564
572
|
// need to use separate label for pie charts
|
@@ -581,6 +589,22 @@
|
|
581
589
|
};
|
582
590
|
}
|
583
591
|
}
|
592
|
+
|
593
|
+
// avoid formatting x-axis labels
|
594
|
+
// by default, Chart.js applies locale
|
595
|
+
if ((chartType === "line" || chartType === "area") && chart.xtype === "number") {
|
596
|
+
if (!options.scales.x.ticks.callback) {
|
597
|
+
options.scales.x.ticks.callback = function (value) {
|
598
|
+
return toStr(value);
|
599
|
+
};
|
600
|
+
}
|
601
|
+
|
602
|
+
if (!options.plugins.tooltip.callbacks.title) {
|
603
|
+
options.plugins.tooltip.callbacks.title = function (context) {
|
604
|
+
return toStr(context[0].parsed.x);
|
605
|
+
};
|
606
|
+
}
|
607
|
+
}
|
584
608
|
}
|
585
609
|
|
586
610
|
function maxAbsY(series) {
|
@@ -881,7 +905,11 @@
|
|
881
905
|
}
|
882
906
|
|
883
907
|
if (!options.scales.x.time.tooltipFormat) {
|
884
|
-
if (
|
908
|
+
if (timeUnit === "year") {
|
909
|
+
options.scales.x.time.tooltipFormat = "yyyy";
|
910
|
+
} else if (timeUnit === "month") {
|
911
|
+
options.scales.x.time.tooltipFormat = "MMM yyyy";
|
912
|
+
} else if (timeUnit === "week" || timeUnit === "day") {
|
885
913
|
options.scales.x.time.tooltipFormat = "PP";
|
886
914
|
} else if (timeUnit === "hour") {
|
887
915
|
options.scales.x.time.tooltipFormat = "MMM d, h a";
|
@@ -904,12 +932,16 @@
|
|
904
932
|
};
|
905
933
|
|
906
934
|
defaultExport$2.prototype.renderLineChart = function renderLineChart (chart, chartType) {
|
935
|
+
if (!chartType) {
|
936
|
+
chartType = "line";
|
937
|
+
}
|
938
|
+
|
907
939
|
var chartOptions = {};
|
908
940
|
|
909
941
|
var options = jsOptions$2(chart, merge(chartOptions, chart.options));
|
910
942
|
setFormatOptions$1(chart, options, chartType);
|
911
943
|
|
912
|
-
var data = createDataTable(chart, options, chartType
|
944
|
+
var data = createDataTable(chart, options, chartType);
|
913
945
|
|
914
946
|
if (chart.xtype === "number") {
|
915
947
|
options.scales.x.type = options.scales.x.type || "linear";
|
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: 5.0.
|
4
|
+
version: 5.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Kane
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-01-
|
11
|
+
date: 2023-01-19 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description:
|
14
14
|
email: andrew@ankane.org
|