chartist-rails 0.9.5 → 0.9.7
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/README.md +1 -1
- data/chartist-rails-0.9.5.gem +0 -0
- data/chartist-rails.gemspec +1 -1
- data/lib/chartist-rails/version.rb +1 -1
- data/vendor/assets/javascripts/chartist.js +125 -88
- data/vendor/assets/javascripts/chartist.min.js +8 -7
- data/vendor/assets/javascripts/chartist.min.js.map +1 -1
- data/vendor/assets/stylesheets/chartist.scss +1 -1
- data/vendor/assets/stylesheets/settings/_chartist-settings.scss +1 -1
- metadata +4 -4
- data/chartist-rails-0.9.4.gem +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: baa734d47f6a94e18ccf95a67bf02ffc4e063137
|
4
|
+
data.tar.gz: 47b95f795fb34402f81f29dc9965621a8805cd1a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5934347b5d3811cb604a449f7e2dac2a09dced09b8685de615bbc50ad9401b093b097b71a6833e33fecdeb968831f97f1f1acce8463d8c0ffaf418b330ce79fa
|
7
|
+
data.tar.gz: 85b27ebe26c04aece2aa28995a96740b13dcf3b7b9f354a564de4274daa98962b1d550832991bc2e359ef029cb166c4bc3aaec0493f134ad7eda59fb8ef78bd4
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Chartist::Rails
|
2
2
|
|
3
|
-
This gem is a wrapper for the [Charist.js](https://github.com/gionkunz/chartist-js) library (v0.9.
|
3
|
+
This gem is a wrapper for the [Charist.js](https://github.com/gionkunz/chartist-js) library (v0.9.7).
|
4
4
|
The state of this gem is that it is fully functional, but you can not change the settings yet.
|
5
5
|
I am currently working on a generator so that you can customize the settings file to your liking.
|
6
6
|
|
Binary file
|
data/chartist-rails.gemspec
CHANGED
@@ -9,7 +9,7 @@ Gem::Specification.new do |spec|
|
|
9
9
|
spec.authors = ["AnthonyBobsin"]
|
10
10
|
spec.email = ["bobsinj@gmail.com"]
|
11
11
|
spec.summary = %q{Vendors the Chartist.js library for use with the Rail's assets pipeline.}
|
12
|
-
spec.description = %q{Current using Chartist version 0.9.
|
12
|
+
spec.description = %q{Current using Chartist version 0.9.7}
|
13
13
|
spec.homepage = "https://github.com/AnthonyBobsin/chartist-rails"
|
14
14
|
spec.license = "MIT"
|
15
15
|
|
@@ -14,10 +14,11 @@
|
|
14
14
|
}
|
15
15
|
}(this, function () {
|
16
16
|
|
17
|
-
/* Chartist.js 0.9.
|
18
|
-
* Copyright ©
|
19
|
-
* Free to use under the WTFPL license.
|
20
|
-
*
|
17
|
+
/* Chartist.js 0.9.7
|
18
|
+
* Copyright © 2016 Gion Kunz
|
19
|
+
* Free to use under either the WTFPL license or the MIT license.
|
20
|
+
* https://raw.githubusercontent.com/gionkunz/chartist-js/master/LICENSE-WTFPL
|
21
|
+
* https://raw.githubusercontent.com/gionkunz/chartist-js/master/LICENSE-MIT
|
21
22
|
*/
|
22
23
|
/**
|
23
24
|
* The core module of Chartist that is mainly providing static functions and higher level functions for chart modules.
|
@@ -25,12 +26,26 @@
|
|
25
26
|
* @module Chartist.Core
|
26
27
|
*/
|
27
28
|
var Chartist = {
|
28
|
-
version: '0.9.
|
29
|
+
version: '0.9.7'
|
29
30
|
};
|
30
31
|
|
31
32
|
(function (window, document, Chartist) {
|
32
33
|
'use strict';
|
33
34
|
|
35
|
+
/**
|
36
|
+
* This object contains all namespaces used within Chartist.
|
37
|
+
*
|
38
|
+
* @memberof Chartist.Core
|
39
|
+
* @type {{svg: string, xmlns: string, xhtml: string, xlink: string, ct: string}}
|
40
|
+
*/
|
41
|
+
Chartist.namespaces = {
|
42
|
+
svg: 'http://www.w3.org/2000/svg',
|
43
|
+
xmlns: 'http://www.w3.org/2000/xmlns/',
|
44
|
+
xhtml: 'http://www.w3.org/1999/xhtml',
|
45
|
+
xlink: 'http://www.w3.org/1999/xlink',
|
46
|
+
ct: 'http://gionkunz.github.com/chartist-js/ct'
|
47
|
+
};
|
48
|
+
|
34
49
|
/**
|
35
50
|
* Helps to simplify functional style code
|
36
51
|
*
|
@@ -311,7 +326,7 @@ var Chartist = {
|
|
311
326
|
// Check if there is a previous SVG element in the container that contains the Chartist XML namespace and remove it
|
312
327
|
// Since the DOM API does not support namespaces we need to manually search the returned list http://www.w3.org/TR/selectors-api/
|
313
328
|
Array.prototype.slice.call(container.querySelectorAll('svg')).filter(function filterChartistSvgObjects(svg) {
|
314
|
-
return svg.getAttributeNS(
|
329
|
+
return svg.getAttributeNS(Chartist.namespaces.xmlns, 'ct');
|
315
330
|
}).forEach(function removePreviousElement(svg) {
|
316
331
|
container.removeChild(svg);
|
317
332
|
});
|
@@ -330,6 +345,44 @@ var Chartist = {
|
|
330
345
|
return svg;
|
331
346
|
};
|
332
347
|
|
348
|
+
/**
|
349
|
+
* Ensures that the data object passed as second argument to the charts is present and correctly initialized.
|
350
|
+
*
|
351
|
+
* @param {Object} data The data object that is passed as second argument to the charts
|
352
|
+
* @return {Object} The normalized data object
|
353
|
+
*/
|
354
|
+
Chartist.normalizeData = function(data) {
|
355
|
+
// Ensure data is present otherwise enforce
|
356
|
+
data = data || {series: [], labels: []};
|
357
|
+
data.series = data.series || [];
|
358
|
+
data.labels = data.labels || [];
|
359
|
+
|
360
|
+
// Check if we should generate some labels based on existing series data
|
361
|
+
if (data.series.length > 0 && data.labels.length === 0) {
|
362
|
+
var normalized = Chartist.getDataArray(data),
|
363
|
+
labelCount;
|
364
|
+
|
365
|
+
// If all elements of the normalized data array are arrays we're dealing with
|
366
|
+
// data from Bar or Line charts and we need to find the largest series if they are un-even
|
367
|
+
if (normalized.every(function(value) {
|
368
|
+
return value instanceof Array;
|
369
|
+
})) {
|
370
|
+
// Getting the series with the the most elements
|
371
|
+
labelCount = Math.max.apply(null, normalized.map(function(series) {
|
372
|
+
return series.length;
|
373
|
+
}));
|
374
|
+
} else {
|
375
|
+
// We're dealing with Pie data so we just take the normalized array length
|
376
|
+
labelCount = normalized.length;
|
377
|
+
}
|
378
|
+
|
379
|
+
// Setting labels to an array with emptry strings using our labelCount estimated above
|
380
|
+
data.labels = Chartist.times(labelCount).map(function() {
|
381
|
+
return '';
|
382
|
+
});
|
383
|
+
}
|
384
|
+
return data;
|
385
|
+
};
|
333
386
|
|
334
387
|
/**
|
335
388
|
* Reverses the series, labels and series data arrays.
|
@@ -532,9 +585,13 @@ var Chartist = {
|
|
532
585
|
} else if (highLow.low < 0) {
|
533
586
|
// If we have the same negative value for the bounds we set bounds.high to 0
|
534
587
|
highLow.high = 0;
|
535
|
-
} else {
|
588
|
+
} else if (highLow.high > 0) {
|
536
589
|
// If we have the same positive value for the bounds we set bounds.low to 0
|
537
590
|
highLow.low = 0;
|
591
|
+
} else {
|
592
|
+
// If data array was empty, values are Number.MAX_VALUE and -Number.MAX_VALUE. Set bounds to prevent errors
|
593
|
+
highLow.high = 1;
|
594
|
+
highLow.low = 0;
|
538
595
|
}
|
539
596
|
}
|
540
597
|
|
@@ -1158,10 +1215,13 @@ var Chartist = {
|
|
1158
1215
|
// This is necessary to treat "holes" in line charts
|
1159
1216
|
var segments = splitIntoSegments(pathCoordinates, valueData);
|
1160
1217
|
|
1161
|
-
|
1162
|
-
|
1163
|
-
|
1164
|
-
|
1218
|
+
if(!segments.length) {
|
1219
|
+
// If there were no segments return 'Chartist.Interpolation.none'
|
1220
|
+
return Chartist.Interpolation.none()([]);
|
1221
|
+
} else if(segments.length > 1) {
|
1222
|
+
// If the split resulted in more that one segment we need to interpolate each segment individually and join them
|
1223
|
+
// afterwards together into a single path.
|
1224
|
+
var paths = [];
|
1165
1225
|
// For each segment we will recurse the cardinal function
|
1166
1226
|
segments.forEach(function(segment) {
|
1167
1227
|
paths.push(cardinal(segment.pathCoordinates, segment.valueData));
|
@@ -1677,16 +1737,6 @@ var Chartist = {
|
|
1677
1737
|
(function(window, document, Chartist) {
|
1678
1738
|
'use strict';
|
1679
1739
|
|
1680
|
-
var svgNs = 'http://www.w3.org/2000/svg',
|
1681
|
-
xmlNs = 'http://www.w3.org/2000/xmlns/',
|
1682
|
-
xhtmlNs = 'http://www.w3.org/1999/xhtml';
|
1683
|
-
|
1684
|
-
Chartist.xmlNs = {
|
1685
|
-
qualifiedName: 'xmlns:ct',
|
1686
|
-
prefix: 'ct',
|
1687
|
-
uri: 'http://gionkunz.github.com/chartist-js/ct'
|
1688
|
-
};
|
1689
|
-
|
1690
1740
|
/**
|
1691
1741
|
* Chartist.Svg creates a new SVG object wrapper with a starting element. You can use the wrapper to fluently create sub-elements and modify them.
|
1692
1742
|
*
|
@@ -1703,11 +1753,13 @@ var Chartist = {
|
|
1703
1753
|
if(name instanceof Element) {
|
1704
1754
|
this._node = name;
|
1705
1755
|
} else {
|
1706
|
-
this._node = document.createElementNS(
|
1756
|
+
this._node = document.createElementNS(Chartist.namespaces.svg, name);
|
1707
1757
|
|
1708
1758
|
// If this is an SVG element created then custom namespace
|
1709
1759
|
if(name === 'svg') {
|
1710
|
-
this.
|
1760
|
+
this.attr({
|
1761
|
+
'xmlns:ct': Chartist.namespaces.ct
|
1762
|
+
});
|
1711
1763
|
}
|
1712
1764
|
}
|
1713
1765
|
|
@@ -1733,7 +1785,7 @@ var Chartist = {
|
|
1733
1785
|
*
|
1734
1786
|
* @memberof Chartist.Svg
|
1735
1787
|
* @param {Object|String} attributes An object with properties that will be added as attributes to the SVG element that is created. Attributes with undefined values will not be added. If this parameter is a String then the function is used as a getter and will return the attribute value.
|
1736
|
-
* @param {String} ns If specified, the
|
1788
|
+
* @param {String} ns If specified, the attribute will be obtained using getAttributeNs. In order to write namepsaced attributes you can use the namespace:attribute notation within the attributes object.
|
1737
1789
|
* @return {Object|String} The current wrapper object will be returned so it can be used for chaining or the attribute value if used as getter function.
|
1738
1790
|
*/
|
1739
1791
|
function attr(attributes, ns) {
|
@@ -1751,8 +1803,9 @@ var Chartist = {
|
|
1751
1803
|
return;
|
1752
1804
|
}
|
1753
1805
|
|
1754
|
-
if(
|
1755
|
-
|
1806
|
+
if (key.indexOf(':') !== -1) {
|
1807
|
+
var namespacedAttribute = key.split(':');
|
1808
|
+
this._node.setAttributeNS(Chartist.namespaces[namespacedAttribute[0]], key, attributes[key]);
|
1756
1809
|
} else {
|
1757
1810
|
this._node.setAttribute(key, attributes[key]);
|
1758
1811
|
}
|
@@ -1843,7 +1896,7 @@ var Chartist = {
|
|
1843
1896
|
}
|
1844
1897
|
|
1845
1898
|
// Adding namespace to content element
|
1846
|
-
content.setAttribute('xmlns',
|
1899
|
+
content.setAttribute('xmlns', Chartist.namespaces.xmlns);
|
1847
1900
|
|
1848
1901
|
// Creating the foreignObject without required extension attribute (as described here
|
1849
1902
|
// http://www.w3.org/TR/SVG/extend.html#ForeignObjectElement)
|
@@ -1981,43 +2034,23 @@ var Chartist = {
|
|
1981
2034
|
}
|
1982
2035
|
|
1983
2036
|
/**
|
1984
|
-
*
|
1985
|
-
* This is a workaround. Firefox throws an NS_ERROR_FAILURE error if getBBox() is called on an invisible node.
|
1986
|
-
* See [NS_ERROR_FAILURE: Component returned failure code: 0x80004005](http://jsfiddle.net/sym3tri/kWWDK/)
|
1987
|
-
*
|
1988
|
-
* @memberof Chartist.Svg
|
1989
|
-
* @param {SVGElement} node The svg node to
|
1990
|
-
* @param {String} prop The property to fetch (ex.: height, width, ...)
|
1991
|
-
* @returns {Number} The value of the given bbox property
|
1992
|
-
*/
|
1993
|
-
function getBBoxProperty(node, prop) {
|
1994
|
-
try {
|
1995
|
-
return node.getBBox()[prop];
|
1996
|
-
} catch(e) {}
|
1997
|
-
|
1998
|
-
return 0;
|
1999
|
-
}
|
2000
|
-
|
2001
|
-
/**
|
2002
|
-
* Get element height with fallback to svg BoundingBox or parent container dimensions:
|
2003
|
-
* See [bugzilla.mozilla.org](https://bugzilla.mozilla.org/show_bug.cgi?id=530985)
|
2037
|
+
* Get element height using `getBoundingClientRect`
|
2004
2038
|
*
|
2005
2039
|
* @memberof Chartist.Svg
|
2006
2040
|
* @return {Number} The elements height in pixels
|
2007
2041
|
*/
|
2008
2042
|
function height() {
|
2009
|
-
return this._node.
|
2043
|
+
return this._node.getBoundingClientRect().height;
|
2010
2044
|
}
|
2011
2045
|
|
2012
2046
|
/**
|
2013
|
-
* Get element width
|
2014
|
-
* See [bugzilla.mozilla.org](https://bugzilla.mozilla.org/show_bug.cgi?id=530985)
|
2047
|
+
* Get element width using `getBoundingClientRect`
|
2015
2048
|
*
|
2016
2049
|
* @memberof Chartist.Core
|
2017
2050
|
* @return {Number} The elements width in pixels
|
2018
2051
|
*/
|
2019
2052
|
function width() {
|
2020
|
-
return this._node.
|
2053
|
+
return this._node.getBoundingClientRect().width;
|
2021
2054
|
}
|
2022
2055
|
|
2023
2056
|
/**
|
@@ -2725,7 +2758,7 @@ var Chartist = {
|
|
2725
2758
|
}
|
2726
2759
|
|
2727
2760
|
// Skip grid lines and labels where interpolated label values are falsey (execpt for 0)
|
2728
|
-
if(
|
2761
|
+
if(Chartist.isFalseyButZero(labelValues[index]) && labelValues[index] !== '') {
|
2729
2762
|
return;
|
2730
2763
|
}
|
2731
2764
|
|
@@ -3042,6 +3075,7 @@ var Chartist = {
|
|
3042
3075
|
*
|
3043
3076
|
*/
|
3044
3077
|
function createChart(options) {
|
3078
|
+
this.data = Chartist.normalizeData(this.data);
|
3045
3079
|
var data = {
|
3046
3080
|
raw: this.data,
|
3047
3081
|
normalized: Chartist.getDataArray(this.data, options.reverseData, true)
|
@@ -3084,9 +3118,9 @@ var Chartist = {
|
|
3084
3118
|
|
3085
3119
|
// Write attributes to series group element. If series name or meta is undefined the attributes will not be written
|
3086
3120
|
seriesElement.attr({
|
3087
|
-
'series-name': series.name,
|
3088
|
-
'meta': Chartist.serialize(series.meta)
|
3089
|
-
}
|
3121
|
+
'ct:series-name': series.name,
|
3122
|
+
'ct:meta': Chartist.serialize(series.meta)
|
3123
|
+
});
|
3090
3124
|
|
3091
3125
|
// Use series class from series data or if not set generate one
|
3092
3126
|
seriesElement.addClass([
|
@@ -3136,11 +3170,9 @@ var Chartist = {
|
|
3136
3170
|
x2: pathElement.x + 0.01,
|
3137
3171
|
y2: pathElement.y
|
3138
3172
|
}, options.classNames.point).attr({
|
3139
|
-
'value': [pathElement.data.value.x, pathElement.data.value.y].filter(
|
3140
|
-
|
3141
|
-
|
3142
|
-
'meta': pathElement.data.meta
|
3143
|
-
}, Chartist.xmlNs.uri);
|
3173
|
+
'ct:value': [pathElement.data.value.x, pathElement.data.value.y].filter(Chartist.isNum).join(','),
|
3174
|
+
'ct:meta': pathElement.data.meta
|
3175
|
+
});
|
3144
3176
|
|
3145
3177
|
this.eventEmitter.emit('draw', {
|
3146
3178
|
type: 'point',
|
@@ -3214,9 +3246,7 @@ var Chartist = {
|
|
3214
3246
|
// and adding the created DOM elements to the correct series group
|
3215
3247
|
var area = seriesElement.elem('path', {
|
3216
3248
|
d: areaPath.stringify()
|
3217
|
-
}, options.classNames.area, true)
|
3218
|
-
'values': data.normalized[seriesIndex]
|
3219
|
-
}, Chartist.xmlNs.uri);
|
3249
|
+
}, options.classNames.area, true);
|
3220
3250
|
|
3221
3251
|
// Emit an event for each area that was drawn
|
3222
3252
|
this.eventEmitter.emit('draw', {
|
@@ -3302,7 +3332,7 @@ var Chartist = {
|
|
3302
3332
|
* ]
|
3303
3333
|
* };
|
3304
3334
|
*
|
3305
|
-
* // In
|
3335
|
+
* // In addition to the regular options we specify responsive option overrides that will override the default configutation based on the matching media queries.
|
3306
3336
|
* var responsiveOptions = [
|
3307
3337
|
* ['screen and (min-width: 641px) and (max-width: 1024px)', {
|
3308
3338
|
* showPoint: false,
|
@@ -3410,8 +3440,6 @@ var Chartist = {
|
|
3410
3440
|
high: undefined,
|
3411
3441
|
// Overriding the natural low of the chart allows you to zoom in or limit the charts lowest displayed value
|
3412
3442
|
low: undefined,
|
3413
|
-
// Use only integer values (whole numbers) for the scale steps
|
3414
|
-
onlyInteger: false,
|
3415
3443
|
// Padding of the chart drawing area to the container element and labels as a number or padding object {top: 5, right: 5, bottom: 5, left: 5}
|
3416
3444
|
chartPadding: {
|
3417
3445
|
top: 15,
|
@@ -3454,6 +3482,7 @@ var Chartist = {
|
|
3454
3482
|
*
|
3455
3483
|
*/
|
3456
3484
|
function createChart(options) {
|
3485
|
+
this.data = Chartist.normalizeData(this.data);
|
3457
3486
|
var data = {
|
3458
3487
|
raw: this.data,
|
3459
3488
|
normalized: options.distributeSeries ? Chartist.getDataArray(this.data, options.reverseData, options.horizontalBars ? 'x' : 'y').map(function(value) {
|
@@ -3476,15 +3505,15 @@ var Chartist = {
|
|
3476
3505
|
var seriesGroup = this.svg.elem('g');
|
3477
3506
|
var labelGroup = this.svg.elem('g').addClass(options.classNames.labelGroup);
|
3478
3507
|
|
3479
|
-
if(options.stackBars) {
|
3508
|
+
if(options.stackBars && data.normalized.length !== 0) {
|
3480
3509
|
// If stacked bars we need to calculate the high low from stacked values from each series
|
3481
3510
|
var serialSums = Chartist.serialMap(data.normalized, function serialSums() {
|
3482
3511
|
return Array.prototype.slice.call(arguments).map(function(value) {
|
3483
3512
|
return value;
|
3484
3513
|
}).reduce(function(prev, curr) {
|
3485
3514
|
return {
|
3486
|
-
x: prev.x + curr.x || 0,
|
3487
|
-
y: prev.y + curr.y || 0
|
3515
|
+
x: prev.x + (curr && curr.x) || 0,
|
3516
|
+
y: prev.y + (curr && curr.y) || 0
|
3488
3517
|
};
|
3489
3518
|
}, {x: 0, y: 0});
|
3490
3519
|
});
|
@@ -3600,9 +3629,9 @@ var Chartist = {
|
|
3600
3629
|
|
3601
3630
|
// Write attributes to series group element. If series name or meta is undefined the attributes will not be written
|
3602
3631
|
seriesElement.attr({
|
3603
|
-
'series-name': series.name,
|
3604
|
-
'meta': Chartist.serialize(series.meta)
|
3605
|
-
}
|
3632
|
+
'ct:series-name': series.name,
|
3633
|
+
'ct:meta': Chartist.serialize(series.meta)
|
3634
|
+
});
|
3606
3635
|
|
3607
3636
|
// Use series class from series data or if not set generate one
|
3608
3637
|
seriesElement.addClass([
|
@@ -3691,11 +3720,9 @@ var Chartist = {
|
|
3691
3720
|
|
3692
3721
|
// Create bar element
|
3693
3722
|
bar = seriesElement.elem('line', positions, options.classNames.bar).attr({
|
3694
|
-
'value': [value.x, value.y].filter(
|
3695
|
-
|
3696
|
-
|
3697
|
-
'meta': Chartist.getMetaData(series, valueIndex)
|
3698
|
-
}, Chartist.xmlNs.uri);
|
3723
|
+
'ct:value': [value.x, value.y].filter(Chartist.isNum).join(','),
|
3724
|
+
'ct:meta': Chartist.getMetaData(series, valueIndex)
|
3725
|
+
});
|
3699
3726
|
|
3700
3727
|
this.eventEmitter.emit('draw', Chartist.extend({
|
3701
3728
|
type: 'bar',
|
@@ -3826,7 +3853,9 @@ var Chartist = {
|
|
3826
3853
|
// Label direction can be 'neutral', 'explode' or 'implode'. The labels anchor will be positioned based on those settings as well as the fact if the labels are on the right or left side of the center of the chart. Usually explode is useful when labels are positioned far away from the center.
|
3827
3854
|
labelDirection: 'neutral',
|
3828
3855
|
// If true the whole data is reversed including labels, the series order as well as the whole series data arrays.
|
3829
|
-
reverseData: false
|
3856
|
+
reverseData: false,
|
3857
|
+
// If true empty values will be ignored to avoid drawing unncessary slices and labels
|
3858
|
+
ignoreEmptyValues: false
|
3830
3859
|
};
|
3831
3860
|
|
3832
3861
|
/**
|
@@ -3857,6 +3886,7 @@ var Chartist = {
|
|
3857
3886
|
* @param options
|
3858
3887
|
*/
|
3859
3888
|
function createChart(options) {
|
3889
|
+
this.data = Chartist.normalizeData(this.data);
|
3860
3890
|
var seriesGroups = [],
|
3861
3891
|
labelsGroup,
|
3862
3892
|
chartRect,
|
@@ -3921,13 +3951,16 @@ var Chartist = {
|
|
3921
3951
|
// Draw the series
|
3922
3952
|
// initialize series groups
|
3923
3953
|
for (var i = 0; i < this.data.series.length; i++) {
|
3954
|
+
// If current value is zero and we are ignoring empty values then skip to next value
|
3955
|
+
if (dataArray[i] === 0 && options.ignoreEmptyValues) continue;
|
3956
|
+
|
3924
3957
|
var series = this.data.series[i];
|
3925
3958
|
seriesGroups[i] = this.svg.elem('g', null, null, true);
|
3926
3959
|
|
3927
3960
|
// If the series is an object and contains a name or meta data we add a custom attribute
|
3928
3961
|
seriesGroups[i].attr({
|
3929
|
-
'series-name': series.name
|
3930
|
-
}
|
3962
|
+
'ct:series-name': series.name
|
3963
|
+
});
|
3931
3964
|
|
3932
3965
|
// Use series class from series data or if not set generate one
|
3933
3966
|
seriesGroups[i].addClass([
|
@@ -3936,13 +3969,17 @@ var Chartist = {
|
|
3936
3969
|
].join(' '));
|
3937
3970
|
|
3938
3971
|
var endAngle = startAngle + dataArray[i] / totalDataSum * 360;
|
3972
|
+
|
3973
|
+
// Use slight offset so there are no transparent hairline issues
|
3974
|
+
var overlappigStartAngle = Math.max(0, startAngle - (i === 0 || hasSingleValInSeries ? 0 : 0.2));
|
3975
|
+
|
3939
3976
|
// If we need to draw the arc for all 360 degrees we need to add a hack where we close the circle
|
3940
3977
|
// with Z and use 359.99 degrees
|
3941
|
-
if(endAngle -
|
3942
|
-
endAngle
|
3978
|
+
if(endAngle - overlappigStartAngle >= 359.99) {
|
3979
|
+
endAngle = overlappigStartAngle + 359.99;
|
3943
3980
|
}
|
3944
3981
|
|
3945
|
-
var start = Chartist.polarToCartesian(center.x, center.y, radius,
|
3982
|
+
var start = Chartist.polarToCartesian(center.x, center.y, radius, overlappigStartAngle),
|
3946
3983
|
end = Chartist.polarToCartesian(center.x, center.y, radius, endAngle);
|
3947
3984
|
|
3948
3985
|
// Create a new path element for the pie chart. If this isn't a donut chart we should close the path for a correct stroke
|
@@ -3963,9 +4000,9 @@ var Chartist = {
|
|
3963
4000
|
|
3964
4001
|
// Adding the pie series value to the path
|
3965
4002
|
pathElement.attr({
|
3966
|
-
'value': dataArray[i],
|
3967
|
-
'meta': Chartist.serialize(series.meta)
|
3968
|
-
}
|
4003
|
+
'ct:value': dataArray[i],
|
4004
|
+
'ct:meta': Chartist.serialize(series.meta)
|
4005
|
+
});
|
3969
4006
|
|
3970
4007
|
// If this is a donut, we add the stroke-width as style attribute
|
3971
4008
|
if(options.donut) {
|
@@ -3995,7 +4032,7 @@ var Chartist = {
|
|
3995
4032
|
if(options.showLabel) {
|
3996
4033
|
// Position at the labelRadius distance from center and between start and end angle
|
3997
4034
|
var labelPosition = Chartist.polarToCartesian(center.x, center.y, labelRadius, startAngle + (endAngle - startAngle) / 2),
|
3998
|
-
interpolatedValue = options.labelInterpolationFnc(this.data.labels ? this.data.labels[i] : dataArray[i], i);
|
4035
|
+
interpolatedValue = options.labelInterpolationFnc(this.data.labels && !Chartist.isFalseyButZero(this.data.labels[i]) ? this.data.labels[i] : dataArray[i], i);
|
3999
4036
|
|
4000
4037
|
if(interpolatedValue || interpolatedValue === 0) {
|
4001
4038
|
var labelElement = labelsGroup.elem('text', {
|
@@ -4017,7 +4054,7 @@ var Chartist = {
|
|
4017
4054
|
}
|
4018
4055
|
}
|
4019
4056
|
|
4020
|
-
// Set next startAngle to current endAngle.
|
4057
|
+
// Set next startAngle to current endAngle.
|
4021
4058
|
// (except for last slice)
|
4022
4059
|
startAngle = endAngle;
|
4023
4060
|
}
|