chartist 1.1.2 → 1.2.0

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.
Files changed (38) hide show
  1. package/README.md +1 -1
  2. package/dist/_settings.scss +89 -0
  3. package/dist/axes/Axis.d.ts.map +1 -1
  4. package/dist/charts/BarChart/BarChart.d.ts +4 -1
  5. package/dist/charts/BarChart/BarChart.d.ts.map +1 -1
  6. package/dist/charts/BarChart/BarChart.types.d.ts +25 -0
  7. package/dist/charts/BarChart/BarChart.types.d.ts.map +1 -1
  8. package/dist/charts/LineChart/LineChart.d.ts +6 -1
  9. package/dist/charts/LineChart/LineChart.d.ts.map +1 -1
  10. package/dist/charts/LineChart/LineChart.types.d.ts +30 -0
  11. package/dist/charts/LineChart/LineChart.types.d.ts.map +1 -1
  12. package/dist/charts/PieChart/PieChart.d.ts +10 -0
  13. package/dist/charts/PieChart/PieChart.d.ts.map +1 -1
  14. package/dist/charts/PieChart/PieChart.types.d.ts +42 -0
  15. package/dist/charts/PieChart/PieChart.types.d.ts.map +1 -1
  16. package/dist/core/types.d.ts +61 -0
  17. package/dist/core/types.d.ts.map +1 -1
  18. package/dist/index.cjs +34 -6
  19. package/dist/index.cjs.map +1 -1
  20. package/dist/index.css +1 -1
  21. package/dist/index.css.map +1 -1
  22. package/dist/index.js +34 -6
  23. package/dist/index.js.map +1 -1
  24. package/dist/index.scss +204 -0
  25. package/dist/index.umd.js +1 -1
  26. package/dist/index.umd.js.map +1 -1
  27. package/dist/interpolation/cardinal.d.ts +2 -0
  28. package/dist/interpolation/cardinal.d.ts.map +1 -1
  29. package/dist/interpolation/monotoneCubic.d.ts +2 -0
  30. package/dist/interpolation/monotoneCubic.d.ts.map +1 -1
  31. package/dist/interpolation/none.d.ts +2 -0
  32. package/dist/interpolation/none.d.ts.map +1 -1
  33. package/dist/interpolation/simple.d.ts +2 -0
  34. package/dist/interpolation/simple.d.ts.map +1 -1
  35. package/dist/interpolation/step.d.ts +3 -1
  36. package/dist/interpolation/step.d.ts.map +1 -1
  37. package/dist/utils/functional.d.ts +1 -1
  38. package/package.json +1 -1
package/dist/index.cjs CHANGED
@@ -262,7 +262,7 @@ function extend() {
262
262
  *
263
263
  * For example:
264
264
  * @example
265
- * ```javascript
265
+ * ```ts
266
266
  * const data = [[1, 2], [3], []];
267
267
  * serialMap(data, cb);
268
268
  *
@@ -1612,7 +1612,7 @@ class SvgPath {
1612
1612
  * @return The current path object for easy call chaining.
1613
1613
  */ parse(path) {
1614
1614
  // Parsing the SVG path string into an array of arrays [['M', '10', '10'], ['L', '100', '100']]
1615
- const chunks = path.replace(/([A-Za-z])([0-9])/g, "$1 $2").replace(/([0-9])([A-Za-z])/g, "$1 $2").split(/[\s,]+/).reduce((result, pathElement)=>{
1615
+ const chunks = path.replace(/([A-Za-z])(-?[0-9])/g, "$1 $2").replace(/([0-9])([A-Za-z])/g, "$1 $2").split(/[\s,]+/).reduce((result, pathElement)=>{
1616
1616
  if (pathElement.match(/[A-Za-z]/)) {
1617
1617
  result.push([]);
1618
1618
  }
@@ -1744,6 +1744,7 @@ class SvgPath {
1744
1744
  * This interpolation function does not smooth the path and the result is only containing lines and no curves.
1745
1745
  *
1746
1746
  * @example
1747
+ * ```ts
1747
1748
  * const chart = new LineChart('.ct-chart', {
1748
1749
  * labels: [1, 2, 3, 4, 5],
1749
1750
  * series: [[1, 2, 8, 1, 7]]
@@ -1752,6 +1753,7 @@ class SvgPath {
1752
1753
  * fillHoles: false
1753
1754
  * })
1754
1755
  * });
1756
+ * ```
1755
1757
  */ function none(options) {
1756
1758
  const finalOptions = {
1757
1759
  fillHoles: false,
@@ -1787,6 +1789,7 @@ class SvgPath {
1787
1789
  * All smoothing functions within Chartist are factory functions that accept an options parameter. The simple interpolation function accepts one configuration parameter `divisor`, between 1 and ∞, which controls the smoothing characteristics.
1788
1790
  *
1789
1791
  * @example
1792
+ * ```ts
1790
1793
  * const chart = new LineChart('.ct-chart', {
1791
1794
  * labels: [1, 2, 3, 4, 5],
1792
1795
  * series: [[1, 2, 8, 1, 7]]
@@ -1796,6 +1799,7 @@ class SvgPath {
1796
1799
  * fillHoles: false
1797
1800
  * })
1798
1801
  * });
1802
+ * ```
1799
1803
  *
1800
1804
  * @param options The options of the simple interpolation factory function.
1801
1805
  */ function simple(options) {
@@ -1839,7 +1843,8 @@ class SvgPath {
1839
1843
  * All smoothing functions within Chartist are factory functions that accept an options parameter. The step interpolation function accepts one configuration parameter `postpone`, that can be `true` or `false`. The default value is `true` and will cause the step to occur where the value actually changes. If a different behaviour is needed where the step is shifted to the left and happens before the actual value, this option can be set to `false`.
1840
1844
  *
1841
1845
  * @example
1842
- * var chart = new Chartist.Line('.ct-chart', {
1846
+ * ```ts
1847
+ * const chart = new Chartist.Line('.ct-chart', {
1843
1848
  * labels: [1, 2, 3, 4, 5],
1844
1849
  * series: [[1, 2, 8, 1, 7]]
1845
1850
  * }, {
@@ -1848,6 +1853,7 @@ class SvgPath {
1848
1853
  * fillHoles: false
1849
1854
  * })
1850
1855
  * });
1856
+ * ```
1851
1857
  */ function step(options) {
1852
1858
  const finalOptions = {
1853
1859
  postpone: true,
@@ -1898,6 +1904,7 @@ class SvgPath {
1898
1904
  * All smoothing functions within Chartist are factory functions that accept an options parameter. The cardinal interpolation function accepts one configuration parameter `tension`, between 0 and 1, which controls the smoothing intensity.
1899
1905
  *
1900
1906
  * @example
1907
+ * ```ts
1901
1908
  * const chart = new LineChart('.ct-chart', {
1902
1909
  * labels: [1, 2, 3, 4, 5],
1903
1910
  * series: [[1, 2, 8, 1, 7]]
@@ -1907,6 +1914,7 @@ class SvgPath {
1907
1914
  * fillHoles: false
1908
1915
  * })
1909
1916
  * });
1917
+ * ```
1910
1918
  *
1911
1919
  * @param options The options of the cardinal factory function.
1912
1920
  */ function cardinal(options) {
@@ -1990,6 +1998,7 @@ class SvgPath {
1990
1998
  * All smoothing functions within Chartist are factory functions that accept an options parameter.
1991
1999
  *
1992
2000
  * @example
2001
+ * ```ts
1993
2002
  * const chart = new LineChart('.ct-chart', {
1994
2003
  * labels: [1, 2, 3, 4, 5],
1995
2004
  * series: [[1, 2, 8, 1, 7]]
@@ -1998,6 +2007,7 @@ class SvgPath {
1998
2007
  * fillHoles: false
1999
2008
  * })
2000
2009
  * });
2010
+ * ```
2001
2011
  *
2002
2012
  * @param options The options of the monotoneCubic factory function.
2003
2013
  */ function monotoneCubic(options) {
@@ -2300,7 +2310,7 @@ class Axis {
2300
2310
  // If we don't have a label ahead and we have only two labels in total, we just take the remaining distance to
2301
2311
  // on the whole axis length. We limit that to a minimum of 30 pixel, so that labels close to the border will
2302
2312
  // still be visible inside of the chart padding.
2303
- labelLength = Math.max(this.axisLength - projectedValue, 30);
2313
+ labelLength = Math.max(this.axisLength - projectedValue, this.axisLength / this.ticks.length);
2304
2314
  }
2305
2315
  // Skip grid lines and labels where interpolated label values are falsey (except for 0)
2306
2316
  if (labelValue !== "" && isFalseyButZero(labelValue)) {
@@ -2733,6 +2743,7 @@ class LineChart extends BaseChart {
2733
2743
  * @return An object which exposes the API for the created chart
2734
2744
  *
2735
2745
  * @example
2746
+ * ```ts
2736
2747
  * // Create a simple line chart
2737
2748
  * const data = {
2738
2749
  * // A labels array that can contain any sort of values
@@ -2751,8 +2762,10 @@ class LineChart extends BaseChart {
2751
2762
  *
2752
2763
  * // In the global name space Chartist we call the Line function to initialize a line chart. As a first parameter we pass in a selector where we would like to get our chart created. Second parameter is the actual data object and as a third parameter we pass in our options
2753
2764
  * new LineChart('.ct-chart', data, options);
2765
+ * ```
2754
2766
  *
2755
2767
  * @example
2768
+ * ```ts
2756
2769
  * // Use specific interpolation function with configuration from the Chartist.Interpolation module
2757
2770
  *
2758
2771
  * const chart = new LineChart('.ct-chart', {
@@ -2765,8 +2778,10 @@ class LineChart extends BaseChart {
2765
2778
  * tension: 0.2
2766
2779
  * })
2767
2780
  * });
2781
+ * ```
2768
2782
  *
2769
2783
  * @example
2784
+ * ```ts
2770
2785
  * // Create a line chart with responsive options
2771
2786
  *
2772
2787
  * const data = {
@@ -2801,7 +2816,7 @@ class LineChart extends BaseChart {
2801
2816
  * ];
2802
2817
  *
2803
2818
  * new LineChart('.ct-chart', data, null, responsiveOptions);
2804
- *
2819
+ * ```
2805
2820
  */ constructor(query, data, options, responsiveOptions){
2806
2821
  super(query, data, defaultOptions$2, extend({}, defaultOptions$2, options), responsiveOptions);
2807
2822
  this.data = data;
@@ -3160,6 +3175,7 @@ class BarChart extends BaseChart {
3160
3175
  * @return An object which exposes the API for the created chart
3161
3176
  *
3162
3177
  * @example
3178
+ * ```ts
3163
3179
  * // Create a simple bar chart
3164
3180
  * const data = {
3165
3181
  * labels: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri'],
@@ -3170,8 +3186,10 @@ class BarChart extends BaseChart {
3170
3186
  *
3171
3187
  * // In the global name space Chartist we call the Bar function to initialize a bar chart. As a first parameter we pass in a selector where we would like to get our chart created and as a second parameter we pass our data object.
3172
3188
  * new BarChart('.ct-chart', data);
3189
+ * ```
3173
3190
  *
3174
3191
  * @example
3192
+ * ```ts
3175
3193
  * // This example creates a bipolar grouped bar chart where the boundaries are limitted to -10 and 10
3176
3194
  * new BarChart('.ct-chart', {
3177
3195
  * labels: [1, 2, 3, 4, 5, 6, 7],
@@ -3184,7 +3202,7 @@ class BarChart extends BaseChart {
3184
3202
  * low: -10,
3185
3203
  * high: 10
3186
3204
  * });
3187
- *
3205
+ * ```
3188
3206
  */ constructor(query, data, options, responsiveOptions){
3189
3207
  super(query, data, defaultOptions$1, extend({}, defaultOptions$1, options), responsiveOptions);
3190
3208
  this.data = data;
@@ -3435,20 +3453,25 @@ class PieChart extends BaseChart {
3435
3453
  * @param responsiveOptions Specify an array of responsive option arrays which are a media query and options object pair => [[mediaQueryString, optionsObject],[more...]]
3436
3454
  *
3437
3455
  * @example
3456
+ * ```ts
3438
3457
  * // Simple pie chart example with four series
3439
3458
  * new PieChart('.ct-chart', {
3440
3459
  * series: [10, 2, 4, 3]
3441
3460
  * });
3461
+ * ```
3442
3462
  *
3443
3463
  * @example
3464
+ * ```ts
3444
3465
  * // Drawing a donut chart
3445
3466
  * new PieChart('.ct-chart', {
3446
3467
  * series: [10, 2, 4, 3]
3447
3468
  * }, {
3448
3469
  * donut: true
3449
3470
  * });
3471
+ * ```
3450
3472
  *
3451
3473
  * @example
3474
+ * ```ts
3452
3475
  * // Using donut, startAngle and total to draw a gauge chart
3453
3476
  * new PieChart('.ct-chart', {
3454
3477
  * series: [20, 10, 30, 40]
@@ -3458,8 +3481,10 @@ class PieChart extends BaseChart {
3458
3481
  * startAngle: 270,
3459
3482
  * total: 200
3460
3483
  * });
3484
+ * ```
3461
3485
  *
3462
3486
  * @example
3487
+ * ```ts
3463
3488
  * // Drawing a pie chart with padding and labels that are outside the pie
3464
3489
  * new PieChart('.ct-chart', {
3465
3490
  * series: [20, 10, 30, 40]
@@ -3468,8 +3493,10 @@ class PieChart extends BaseChart {
3468
3493
  * labelOffset: 50,
3469
3494
  * labelDirection: 'explode'
3470
3495
  * });
3496
+ * ```
3471
3497
  *
3472
3498
  * @example
3499
+ * ```ts
3473
3500
  * // Overriding the class names for individual series as well as a name and meta data.
3474
3501
  * // The name will be written as ct:series-name attribute and the meta data will be serialized and written
3475
3502
  * // to a ct:meta attribute.
@@ -3491,6 +3518,7 @@ class PieChart extends BaseChart {
3491
3518
  * meta: 'Meta Three'
3492
3519
  * }]
3493
3520
  * });
3521
+ * ```
3494
3522
  */ constructor(query, data, options, responsiveOptions){
3495
3523
  super(query, data, defaultOptions, extend({}, defaultOptions, options), responsiveOptions);
3496
3524
  this.data = data;