chartkick 5.0.1 → 5.0.2

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.
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * Chart.js v4.2.0
2
+ * Chart.js v4.3.0
3
3
  * https://www.chartjs.org
4
4
  * (c) 2023 Chart.js Contributors
5
5
  * Released under the MIT License
@@ -1589,12 +1589,8 @@
1589
1589
  * @param items
1590
1590
  */
1591
1591
  function _arrayUnique(items) {
1592
- var set = new Set();
1593
- var i, ilen;
1594
- for (i = 0, ilen = items.length; i < ilen; ++i) {
1595
- set.add(items[i]);
1596
- }
1597
- if (set.size === ilen) {
1592
+ var set = new Set(items);
1593
+ if (set.size === items.length) {
1598
1594
  return items;
1599
1595
  }
1600
1596
  return Array.from(set);
@@ -1994,7 +1990,7 @@
1994
1990
  delta = calculateDelta(tickValue, ticks);
1995
1991
  }
1996
1992
  var logDelta = log10(Math.abs(delta));
1997
- var numDecimal = Math.max(Math.min(-1 * Math.floor(logDelta), 20), 0);
1993
+ var numDecimal = isNaN(logDelta) ? 1 : Math.max(Math.min(-1 * Math.floor(logDelta), 20), 0);
1998
1994
  var options = {
1999
1995
  notation: notation,
2000
1996
  minimumFractionDigits: numDecimal,
@@ -2245,12 +2241,22 @@
2245
2241
  _indexable: false
2246
2242
  }
2247
2243
  }, [applyAnimationsDefaults, applyLayoutsDefaults, applyScaleDefaults]);
2244
+
2245
+ /**
2246
+ * Converts the given font object into a CSS font string.
2247
+ * @param font - A font object.
2248
+ * @return The CSS font string. See https://developer.mozilla.org/en-US/docs/Web/CSS/font
2249
+ * @private
2250
+ */
2248
2251
  function toFontString(font) {
2249
2252
  if (!font || isNullOrUndef(font.size) || isNullOrUndef(font.family)) {
2250
2253
  return null;
2251
2254
  }
2252
2255
  return (font.style ? font.style + ' ' : '') + (font.weight ? font.weight + ' ' : '') + font.size + 'px ' + font.family;
2253
2256
  }
2257
+ /**
2258
+ * @private
2259
+ */
2254
2260
  function _measureText(ctx, data, gc, longest, string) {
2255
2261
  var textWidth = data[string];
2256
2262
  if (!textWidth) {
@@ -2262,6 +2268,9 @@
2262
2268
  }
2263
2269
  return longest;
2264
2270
  }
2271
+ /**
2272
+ * @private
2273
+ */ // eslint-disable-next-line complexity
2265
2274
  function _longestText(ctx, font, arrayOfThings, cache) {
2266
2275
  cache = cache || {};
2267
2276
  var data = cache.data = cache.data || {};
@@ -2278,11 +2287,15 @@
2278
2287
  var i, j, jlen, thing, nestedThing;
2279
2288
  for (i = 0; i < ilen; i++) {
2280
2289
  thing = arrayOfThings[i];
2281
- if (thing !== undefined && thing !== null && isArray(thing) !== true) {
2290
+ // Undefined strings and arrays should not be measured
2291
+ if (thing !== undefined && thing !== null && !isArray(thing)) {
2282
2292
  longest = _measureText(ctx, data, gc, longest, thing);
2283
2293
  } else if (isArray(thing)) {
2294
+ // if it is an array lets measure each element
2295
+ // to do maybe simplify this function a bit so we can do this more recursively?
2284
2296
  for (j = 0, jlen = thing.length; j < jlen; j++) {
2285
2297
  nestedThing = thing[j];
2298
+ // Undefined strings and arrays should not be measured
2286
2299
  if (nestedThing !== undefined && nestedThing !== null && !isArray(nestedThing)) {
2287
2300
  longest = _measureText(ctx, data, gc, longest, nestedThing);
2288
2301
  }
@@ -2299,21 +2312,36 @@
2299
2312
  }
2300
2313
  return longest;
2301
2314
  }
2315
+ /**
2316
+ * Returns the aligned pixel value to avoid anti-aliasing blur
2317
+ * @param chart - The chart instance.
2318
+ * @param pixel - A pixel value.
2319
+ * @param width - The width of the element.
2320
+ * @returns The aligned pixel value.
2321
+ * @private
2322
+ */
2302
2323
  function _alignPixel(chart, pixel, width) {
2303
2324
  var devicePixelRatio = chart.currentDevicePixelRatio;
2304
2325
  var halfWidth = width !== 0 ? Math.max(width / 2, 0.5) : 0;
2305
2326
  return Math.round((pixel - halfWidth) * devicePixelRatio) / devicePixelRatio + halfWidth;
2306
2327
  }
2328
+ /**
2329
+ * Clears the entire canvas.
2330
+ */
2307
2331
  function clearCanvas(canvas, ctx) {
2308
2332
  ctx = ctx || canvas.getContext('2d');
2309
2333
  ctx.save();
2334
+ // canvas.width and canvas.height do not consider the canvas transform,
2335
+ // while clearRect does
2310
2336
  ctx.resetTransform();
2311
2337
  ctx.clearRect(0, 0, canvas.width, canvas.height);
2312
2338
  ctx.restore();
2313
2339
  }
2314
2340
  function drawPoint(ctx, options, x, y) {
2341
+ // eslint-disable-next-line @typescript-eslint/no-use-before-define
2315
2342
  drawPointLegend(ctx, options, x, y, null);
2316
2343
  }
2344
+ // eslint-disable-next-line complexity
2317
2345
  function drawPointLegend(ctx, options, x, y, w) {
2318
2346
  var type, xOffset, yOffset, size, cornerRadius, width, xOffsetW, yOffsetW;
2319
2347
  var style = options.pointStyle;
@@ -2336,6 +2364,7 @@
2336
2364
  }
2337
2365
  ctx.beginPath();
2338
2366
  switch (style) {
2367
+ // Default includes circle
2339
2368
  default:
2340
2369
  if (w) {
2341
2370
  ctx.ellipse(x, y, w / 2, radius, 0, 0, TAU);
@@ -2354,6 +2383,13 @@
2354
2383
  ctx.closePath();
2355
2384
  break;
2356
2385
  case 'rectRounded':
2386
+ // NOTE: the rounded rect implementation changed to use `arc` instead of
2387
+ // `quadraticCurveTo` since it generates better results when rect is
2388
+ // almost a circle. 0.516 (instead of 0.5) produces results with visually
2389
+ // closer proportion to the previous impl and it is inscribed in the
2390
+ // circle with `radius`. For more details, see the following PRs:
2391
+ // https://github.com/chartjs/Chart.js/issues/5597
2392
+ // https://github.com/chartjs/Chart.js/issues/5858
2357
2393
  cornerRadius = radius * 0.516;
2358
2394
  size = radius - cornerRadius;
2359
2395
  xOffset = Math.cos(rad + QUARTER_PI) * size;
@@ -2374,6 +2410,7 @@
2374
2410
  break;
2375
2411
  }
2376
2412
  rad += QUARTER_PI;
2413
+ /* falls through */
2377
2414
  case 'rectRot':
2378
2415
  xOffsetW = Math.cos(rad) * (w ? w / 2 : radius);
2379
2416
  xOffset = Math.cos(rad) * radius;
@@ -2387,6 +2424,7 @@
2387
2424
  break;
2388
2425
  case 'crossRot':
2389
2426
  rad += QUARTER_PI;
2427
+ /* falls through */
2390
2428
  case 'cross':
2391
2429
  xOffsetW = Math.cos(rad) * (w ? w / 2 : radius);
2392
2430
  xOffset = Math.cos(rad) * radius;
@@ -2435,8 +2473,15 @@
2435
2473
  ctx.stroke();
2436
2474
  }
2437
2475
  }
2476
+ /**
2477
+ * Returns true if the point is inside the rectangle
2478
+ * @param point - The point to test
2479
+ * @param area - The rectangle
2480
+ * @param margin - allowed margin
2481
+ * @private
2482
+ */
2438
2483
  function _isPointInArea(point, area, margin) {
2439
- margin = margin || 0.5;
2484
+ margin = margin || 0.5; // margin - default is to match rounded decimals
2440
2485
  return !area || point && point.x > area.left - margin && point.x < area.right + margin && point.y > area.top - margin && point.y < area.bottom + margin;
2441
2486
  }
2442
2487
  function clipArea(ctx, area) {
@@ -2448,6 +2493,9 @@
2448
2493
  function unclipArea(ctx) {
2449
2494
  ctx.restore();
2450
2495
  }
2496
+ /**
2497
+ * @private
2498
+ */
2451
2499
  function _steppedLineTo(ctx, previous, target, flip, mode) {
2452
2500
  if (!previous) {
2453
2501
  return ctx.lineTo(target.x, target.y);
@@ -2463,40 +2511,15 @@
2463
2511
  }
2464
2512
  ctx.lineTo(target.x, target.y);
2465
2513
  }
2514
+ /**
2515
+ * @private
2516
+ */
2466
2517
  function _bezierCurveTo(ctx, previous, target, flip) {
2467
2518
  if (!previous) {
2468
2519
  return ctx.lineTo(target.x, target.y);
2469
2520
  }
2470
2521
  ctx.bezierCurveTo(flip ? previous.cp1x : previous.cp2x, flip ? previous.cp1y : previous.cp2y, flip ? target.cp2x : target.cp1x, flip ? target.cp2y : target.cp1y, target.x, target.y);
2471
2522
  }
2472
- function renderText(ctx, text, x, y, font) {
2473
- var opts = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : {};
2474
- var lines = isArray(text) ? text : [text];
2475
- var stroke = opts.strokeWidth > 0 && opts.strokeColor !== '';
2476
- var i, line;
2477
- ctx.save();
2478
- ctx.font = font.string;
2479
- setRenderOpts(ctx, opts);
2480
- for (i = 0; i < lines.length; ++i) {
2481
- line = lines[i];
2482
- if (opts.backdrop) {
2483
- drawBackdrop(ctx, opts.backdrop);
2484
- }
2485
- if (stroke) {
2486
- if (opts.strokeColor) {
2487
- ctx.strokeStyle = opts.strokeColor;
2488
- }
2489
- if (!isNullOrUndef(opts.strokeWidth)) {
2490
- ctx.lineWidth = opts.strokeWidth;
2491
- }
2492
- ctx.strokeText(line, x, y, opts.maxWidth);
2493
- }
2494
- ctx.fillText(line, x, y, opts.maxWidth);
2495
- decorateText(ctx, x, y, line, opts);
2496
- y += font.lineHeight;
2497
- }
2498
- ctx.restore();
2499
- }
2500
2523
  function setRenderOpts(ctx, opts) {
2501
2524
  if (opts.translation) {
2502
2525
  ctx.translate(opts.translation[0], opts.translation[1]);
@@ -2516,6 +2539,13 @@
2516
2539
  }
2517
2540
  function decorateText(ctx, x, y, line, opts) {
2518
2541
  if (opts.strikethrough || opts.underline) {
2542
+ /**
2543
+ * Now that IE11 support has been dropped, we can use more
2544
+ * of the TextMetrics object. The actual bounding boxes
2545
+ * are unflagged in Chrome, Firefox, Edge, and Safari so they
2546
+ * can be safely used.
2547
+ * See https://developer.mozilla.org/en-US/docs/Web/API/TextMetrics#Browser_compatibility
2548
+ */
2519
2549
  var metrics = ctx.measureText(line);
2520
2550
  var left = x - metrics.actualBoundingBoxLeft;
2521
2551
  var right = x + metrics.actualBoundingBoxRight;
@@ -2536,19 +2566,63 @@
2536
2566
  ctx.fillRect(opts.left, opts.top, opts.width, opts.height);
2537
2567
  ctx.fillStyle = oldColor;
2538
2568
  }
2569
+ /**
2570
+ * Render text onto the canvas
2571
+ */
2572
+ function renderText(ctx, text, x, y, font) {
2573
+ var opts = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : {};
2574
+ var lines = isArray(text) ? text : [text];
2575
+ var stroke = opts.strokeWidth > 0 && opts.strokeColor !== '';
2576
+ var i, line;
2577
+ ctx.save();
2578
+ ctx.font = font.string;
2579
+ setRenderOpts(ctx, opts);
2580
+ for (i = 0; i < lines.length; ++i) {
2581
+ line = lines[i];
2582
+ if (opts.backdrop) {
2583
+ drawBackdrop(ctx, opts.backdrop);
2584
+ }
2585
+ if (stroke) {
2586
+ if (opts.strokeColor) {
2587
+ ctx.strokeStyle = opts.strokeColor;
2588
+ }
2589
+ if (!isNullOrUndef(opts.strokeWidth)) {
2590
+ ctx.lineWidth = opts.strokeWidth;
2591
+ }
2592
+ ctx.strokeText(line, x, y, opts.maxWidth);
2593
+ }
2594
+ ctx.fillText(line, x, y, opts.maxWidth);
2595
+ decorateText(ctx, x, y, line, opts);
2596
+ y += Number(font.lineHeight);
2597
+ }
2598
+ ctx.restore();
2599
+ }
2600
+ /**
2601
+ * Add a path of a rectangle with rounded corners to the current sub-path
2602
+ * @param ctx - Context
2603
+ * @param rect - Bounding rect
2604
+ */
2539
2605
  function addRoundedRectPath(ctx, rect) {
2540
2606
  var x = rect.x,
2541
2607
  y = rect.y,
2542
2608
  w = rect.w,
2543
2609
  h = rect.h,
2544
2610
  radius = rect.radius;
2611
+ // top left arc
2545
2612
  ctx.arc(x + radius.topLeft, y + radius.topLeft, radius.topLeft, -HALF_PI, PI, true);
2613
+ // line from top left to bottom left
2546
2614
  ctx.lineTo(x, y + h - radius.bottomLeft);
2615
+ // bottom left arc
2547
2616
  ctx.arc(x + radius.bottomLeft, y + h - radius.bottomLeft, radius.bottomLeft, PI, HALF_PI, true);
2617
+ // line from bottom left to bottom right
2548
2618
  ctx.lineTo(x + w - radius.bottomRight, y + h);
2619
+ // bottom right arc
2549
2620
  ctx.arc(x + w - radius.bottomRight, y + h - radius.bottomRight, radius.bottomRight, HALF_PI, 0, true);
2621
+ // line from bottom right to top right
2550
2622
  ctx.lineTo(x + w, y + radius.topRight);
2623
+ // top right arc
2551
2624
  ctx.arc(x + w - radius.topRight, y + radius.topRight, radius.topRight, 0, -HALF_PI, true);
2625
+ // line from top right to top left
2552
2626
  ctx.lineTo(x + radius.topLeft, y);
2553
2627
  }
2554
2628
  var LINE_HEIGHT = /^(normal|(\d+(?:\.\d+)?)(px|em|%)?)$/;
@@ -2733,52 +2807,94 @@
2733
2807
  function createContext(parentContext, context) {
2734
2808
  return Object.assign(Object.create(parentContext), context);
2735
2809
  }
2810
+
2811
+ /**
2812
+ * Creates a Proxy for resolving raw values for options.
2813
+ * @param scopes - The option scopes to look for values, in resolution order
2814
+ * @param prefixes - The prefixes for values, in resolution order.
2815
+ * @param rootScopes - The root option scopes
2816
+ * @param fallback - Parent scopes fallback
2817
+ * @param getTarget - callback for getting the target for changed values
2818
+ * @returns Proxy
2819
+ * @private
2820
+ */
2736
2821
  function _createResolver(scopes) {
2737
2822
  var _cache;
2738
2823
  var prefixes = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [''];
2739
- var rootScopes = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : scopes;
2824
+ var rootScopes = arguments.length > 2 ? arguments[2] : undefined;
2740
2825
  var fallback = arguments.length > 3 ? arguments[3] : undefined;
2741
2826
  var getTarget = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : function () {
2742
2827
  return scopes[0];
2743
2828
  };
2744
- if (!defined(fallback)) {
2829
+ var finalRootScopes = rootScopes || scopes;
2830
+ if (typeof fallback === 'undefined') {
2745
2831
  fallback = _resolve('_fallback', scopes);
2746
2832
  }
2747
- var cache = (_cache = {}, _defineProperty$w(_cache, Symbol.toStringTag, 'Object'), _defineProperty$w(_cache, "_cacheable", true), _defineProperty$w(_cache, "_scopes", scopes), _defineProperty$w(_cache, "_rootScopes", rootScopes), _defineProperty$w(_cache, "_fallback", fallback), _defineProperty$w(_cache, "_getTarget", getTarget), _defineProperty$w(_cache, "override", function override(scope) {
2748
- return _createResolver([scope].concat(_toConsumableArray(scopes)), prefixes, rootScopes, fallback);
2833
+ var cache = (_cache = {}, _defineProperty$w(_cache, Symbol.toStringTag, 'Object'), _defineProperty$w(_cache, "_cacheable", true), _defineProperty$w(_cache, "_scopes", scopes), _defineProperty$w(_cache, "_rootScopes", finalRootScopes), _defineProperty$w(_cache, "_fallback", fallback), _defineProperty$w(_cache, "_getTarget", getTarget), _defineProperty$w(_cache, "override", function override(scope) {
2834
+ return _createResolver([scope].concat(_toConsumableArray(scopes)), prefixes, finalRootScopes, fallback);
2749
2835
  }), _cache);
2750
2836
  return new Proxy(cache, {
2837
+ /**
2838
+ * A trap for the delete operator.
2839
+ */
2751
2840
  deleteProperty: function deleteProperty(target, prop) {
2752
- delete target[prop];
2753
- delete target._keys;
2754
- delete scopes[0][prop];
2841
+ delete target[prop]; // remove from cache
2842
+ delete target._keys; // remove cached keys
2843
+ delete scopes[0][prop]; // remove from top level scope
2755
2844
  return true;
2756
2845
  },
2846
+ /**
2847
+ * A trap for getting property values.
2848
+ */
2757
2849
  get: function get(target, prop) {
2758
2850
  return _cached(target, prop, function () {
2759
2851
  return _resolveWithPrefixes(prop, prefixes, scopes, target);
2760
2852
  });
2761
2853
  },
2854
+ /**
2855
+ * A trap for Object.getOwnPropertyDescriptor.
2856
+ * Also used by Object.hasOwnProperty.
2857
+ */
2762
2858
  getOwnPropertyDescriptor: function getOwnPropertyDescriptor(target, prop) {
2763
2859
  return Reflect.getOwnPropertyDescriptor(target._scopes[0], prop);
2764
2860
  },
2861
+ /**
2862
+ * A trap for Object.getPrototypeOf.
2863
+ */
2765
2864
  getPrototypeOf: function getPrototypeOf() {
2766
2865
  return Reflect.getPrototypeOf(scopes[0]);
2767
2866
  },
2867
+ /**
2868
+ * A trap for the in operator.
2869
+ */
2768
2870
  has: function has(target, prop) {
2769
2871
  return getKeysFromAllScopes(target).includes(prop);
2770
2872
  },
2873
+ /**
2874
+ * A trap for Object.getOwnPropertyNames and Object.getOwnPropertySymbols.
2875
+ */
2771
2876
  ownKeys: function ownKeys(target) {
2772
2877
  return getKeysFromAllScopes(target);
2773
2878
  },
2879
+ /**
2880
+ * A trap for setting property values.
2881
+ */
2774
2882
  set: function set(target, prop, value) {
2775
2883
  var storage = target._storage || (target._storage = getTarget());
2776
- target[prop] = storage[prop] = value;
2777
- delete target._keys;
2884
+ target[prop] = storage[prop] = value; // set to top level scope + cache
2885
+ delete target._keys; // remove cached keys
2778
2886
  return true;
2779
2887
  }
2780
2888
  });
2781
2889
  }
2890
+ /**
2891
+ * Returns an Proxy for resolving option values with context.
2892
+ * @param proxy - The Proxy returned by `_createResolver`
2893
+ * @param context - Context object for scriptable/indexable options
2894
+ * @param subProxy - The proxy provided for scriptable options
2895
+ * @param descriptorDefaults - Defaults for descriptors
2896
+ * @private
2897
+ */
2782
2898
  function _attachContext(proxy, context, subProxy, descriptorDefaults) {
2783
2899
  var cache = {
2784
2900
  _cacheable: false,
@@ -2795,38 +2911,63 @@
2795
2911
  }
2796
2912
  };
2797
2913
  return new Proxy(cache, {
2914
+ /**
2915
+ * A trap for the delete operator.
2916
+ */
2798
2917
  deleteProperty: function deleteProperty(target, prop) {
2799
- delete target[prop];
2800
- delete proxy[prop];
2918
+ delete target[prop]; // remove from cache
2919
+ delete proxy[prop]; // remove from proxy
2801
2920
  return true;
2802
2921
  },
2922
+ /**
2923
+ * A trap for getting property values.
2924
+ */
2803
2925
  get: function get(target, prop, receiver) {
2804
2926
  return _cached(target, prop, function () {
2805
2927
  return _resolveWithContext(target, prop, receiver);
2806
2928
  });
2807
2929
  },
2930
+ /**
2931
+ * A trap for Object.getOwnPropertyDescriptor.
2932
+ * Also used by Object.hasOwnProperty.
2933
+ */
2808
2934
  getOwnPropertyDescriptor: function getOwnPropertyDescriptor(target, prop) {
2809
2935
  return target._descriptors.allKeys ? Reflect.has(proxy, prop) ? {
2810
2936
  enumerable: true,
2811
2937
  configurable: true
2812
2938
  } : undefined : Reflect.getOwnPropertyDescriptor(proxy, prop);
2813
2939
  },
2940
+ /**
2941
+ * A trap for Object.getPrototypeOf.
2942
+ */
2814
2943
  getPrototypeOf: function getPrototypeOf() {
2815
2944
  return Reflect.getPrototypeOf(proxy);
2816
2945
  },
2946
+ /**
2947
+ * A trap for the in operator.
2948
+ */
2817
2949
  has: function has(target, prop) {
2818
2950
  return Reflect.has(proxy, prop);
2819
2951
  },
2952
+ /**
2953
+ * A trap for Object.getOwnPropertyNames and Object.getOwnPropertySymbols.
2954
+ */
2820
2955
  ownKeys: function ownKeys() {
2821
2956
  return Reflect.ownKeys(proxy);
2822
2957
  },
2958
+ /**
2959
+ * A trap for setting property values.
2960
+ */
2823
2961
  set: function set(target, prop, value) {
2824
- proxy[prop] = value;
2825
- delete target[prop];
2962
+ proxy[prop] = value; // set to proxy
2963
+ delete target[prop]; // remove from cache
2826
2964
  return true;
2827
2965
  }
2828
2966
  });
2829
2967
  }
2968
+ /**
2969
+ * @private
2970
+ */
2830
2971
  function _descriptors(proxy) {
2831
2972
  var defaults = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
2832
2973
  scriptable: true,
@@ -2861,6 +3002,7 @@
2861
3002
  return target[prop];
2862
3003
  }
2863
3004
  var value = resolve();
3005
+ // cache the resolved value
2864
3006
  target[prop] = value;
2865
3007
  return value;
2866
3008
  }
@@ -2869,7 +3011,8 @@
2869
3011
  _context = target._context,
2870
3012
  _subProxy = target._subProxy,
2871
3013
  descriptors = target._descriptors;
2872
- var value = _proxy[prop];
3014
+ var value = _proxy[prop]; // resolve from proxy
3015
+ // resolve with context
2873
3016
  if (isFunction(value) && descriptors.isScriptable(prop)) {
2874
3017
  value = _resolveScriptable(prop, value, target, receiver);
2875
3018
  }
@@ -2877,11 +3020,12 @@
2877
3020
  value = _resolveArray(prop, value, target, descriptors.isIndexable);
2878
3021
  }
2879
3022
  if (needsSubResolver(prop, value)) {
3023
+ // if the resolved value is an object, create a sub resolver for it
2880
3024
  value = _attachContext(value, _context, _subProxy && _subProxy[prop], descriptors);
2881
3025
  }
2882
3026
  return value;
2883
3027
  }
2884
- function _resolveScriptable(prop, value, target, receiver) {
3028
+ function _resolveScriptable(prop, getValue, target, receiver) {
2885
3029
  var _proxy = target._proxy,
2886
3030
  _context = target._context,
2887
3031
  _subProxy = target._subProxy,
@@ -2890,9 +3034,10 @@
2890
3034
  throw new Error('Recursion detected: ' + Array.from(_stack).join('->') + '->' + prop);
2891
3035
  }
2892
3036
  _stack.add(prop);
2893
- value = value(_context, _subProxy || receiver);
3037
+ var value = getValue(_context, _subProxy || receiver);
2894
3038
  _stack["delete"](prop);
2895
3039
  if (needsSubResolver(prop, value)) {
3040
+ // When scriptable option returns an object, create a resolver on that.
2896
3041
  value = createSubResolver(_proxy._scopes, _proxy, prop, value);
2897
3042
  }
2898
3043
  return value;
@@ -2902,9 +3047,10 @@
2902
3047
  _context = target._context,
2903
3048
  _subProxy = target._subProxy,
2904
3049
  descriptors = target._descriptors;
2905
- if (defined(_context.index) && isIndexable(prop)) {
2906
- value = value[_context.index % value.length];
3050
+ if (typeof _context.index !== 'undefined' && isIndexable(prop)) {
3051
+ return value[_context.index % value.length];
2907
3052
  } else if (isObject(value[0])) {
3053
+ // Array of objects, return array or resolvers
2908
3054
  var arr = value;
2909
3055
  var scopes = _proxy._scopes.filter(function (s) {
2910
3056
  return s !== arr;
@@ -2942,10 +3088,14 @@
2942
3088
  if (scope) {
2943
3089
  set.add(scope);
2944
3090
  var fallback = resolveFallback(scope._fallback, key, value);
2945
- if (defined(fallback) && fallback !== key && fallback !== parentFallback) {
3091
+ if (typeof fallback !== 'undefined' && fallback !== key && fallback !== parentFallback) {
3092
+ // When we reach the descriptor that defines a new _fallback, return that.
3093
+ // The fallback will resume to that new scope.
2946
3094
  return fallback;
2947
3095
  }
2948
- } else if (scope === false && defined(parentFallback) && key !== parentFallback) {
3096
+ } else if (scope === false && typeof parentFallback !== 'undefined' && key !== parentFallback) {
3097
+ // Fallback to `false` results to `false`, when falling back to different key.
3098
+ // For example `interaction` from `hover` or `plugins.tooltip` and `animation` from `animations`
2949
3099
  return null;
2950
3100
  }
2951
3101
  }
@@ -2966,7 +3116,7 @@
2966
3116
  if (key === null) {
2967
3117
  return false;
2968
3118
  }
2969
- if (defined(fallback) && fallback !== prop) {
3119
+ if (typeof fallback !== 'undefined' && fallback !== prop) {
2970
3120
  key = addScopesFromKey(set, allScopes, fallback, key, value);
2971
3121
  if (key === null) {
2972
3122
  return false;
@@ -2989,6 +3139,7 @@
2989
3139
  }
2990
3140
  var target = parent[prop];
2991
3141
  if (isArray(target) && isObject(value)) {
3142
+ // For array of objects, the object is used to store updated values
2992
3143
  return value;
2993
3144
  }
2994
3145
  return target || {};
@@ -3001,7 +3152,7 @@
3001
3152
  for (_iterator7.s(); !(_step7 = _iterator7.n()).done;) {
3002
3153
  var prefix = _step7.value;
3003
3154
  value = _resolve(readKey(prefix, prop), scopes);
3004
- if (defined(value)) {
3155
+ if (typeof value !== 'undefined') {
3005
3156
  return needsSubResolver(prop, value) ? createSubResolver(scopes, proxy, prop, value) : value;
3006
3157
  }
3007
3158
  }
@@ -3021,7 +3172,7 @@
3021
3172
  continue;
3022
3173
  }
3023
3174
  var value = scope[key];
3024
- if (defined(value)) {
3175
+ if (typeof value !== 'undefined') {
3025
3176
  return value;
3026
3177
  }
3027
3178
  }
@@ -3912,7 +4063,20 @@
3912
4063
  };
3913
4064
  }
3914
4065
  function styleChanged(style, prevStyle) {
3915
- return prevStyle && JSON.stringify(style) !== JSON.stringify(prevStyle);
4066
+ if (!prevStyle) {
4067
+ return false;
4068
+ }
4069
+ var cache = [];
4070
+ var replacer = function replacer(key, value) {
4071
+ if (!isPatternOrGradient(value)) {
4072
+ return value;
4073
+ }
4074
+ if (!cache.includes(value)) {
4075
+ cache.push(value);
4076
+ }
4077
+ return cache.indexOf(value);
4078
+ };
4079
+ return JSON.stringify(style, replacer) !== JSON.stringify(prevStyle, replacer);
3916
4080
  }
3917
4081
 
3918
4082
  var Animator = /*#__PURE__*/function () {
@@ -6238,7 +6402,7 @@
6238
6402
  return name !== 'spacing';
6239
6403
  },
6240
6404
  _indexable: function _indexable(name) {
6241
- return name !== 'spacing';
6405
+ return name !== 'spacing' && !name.startsWith('borderDash') && !name.startsWith('hoverBorderDash');
6242
6406
  }
6243
6407
  });
6244
6408
  _defineProperty$w(DoughnutController, "overrides", {
@@ -6875,8 +7039,8 @@
6875
7039
  BubbleController: BubbleController,
6876
7040
  DoughnutController: DoughnutController,
6877
7041
  LineController: LineController,
6878
- PolarAreaController: PolarAreaController,
6879
7042
  PieController: PieController,
7043
+ PolarAreaController: PolarAreaController,
6880
7044
  RadarController: RadarController,
6881
7045
  ScatterController: ScatterController
6882
7046
  });
@@ -6898,6 +7062,7 @@
6898
7062
  var DateAdapterBase = /*#__PURE__*/function () {
6899
7063
  function DateAdapterBase(options) {
6900
7064
  _classCallCheck$x(this, DateAdapterBase);
7065
+ _defineProperty$w(this, "options", void 0);
6901
7066
  this.options = options || {};
6902
7067
  }
6903
7068
  // eslint-disable-next-line @typescript-eslint/no-empty-function
@@ -7418,18 +7583,18 @@
7418
7583
  stack.placed += width;
7419
7584
  y = box.bottom;
7420
7585
  } else {
7421
- var height1 = chartArea.h * weight;
7422
- var width1 = stack.size || box.width;
7586
+ var _height = chartArea.h * weight;
7587
+ var _width = stack.size || box.width;
7423
7588
  if (defined(stack.start)) {
7424
7589
  x = stack.start;
7425
7590
  }
7426
7591
  if (box.fullSize) {
7427
- setBoxDims(box, x, userPadding.top, width1, params.outerHeight - userPadding.bottom - userPadding.top);
7592
+ setBoxDims(box, x, userPadding.top, _width, params.outerHeight - userPadding.bottom - userPadding.top);
7428
7593
  } else {
7429
- setBoxDims(box, x, chartArea.top + stack.placed, width1, height1);
7594
+ setBoxDims(box, x, chartArea.top + stack.placed, _width, _height);
7430
7595
  }
7431
7596
  stack.start = x;
7432
- stack.placed += height1;
7597
+ stack.placed += _height;
7433
7598
  x = box.right;
7434
7599
  }
7435
7600
  }
@@ -7912,7 +8077,11 @@
7912
8077
  var Element = /*#__PURE__*/function () {
7913
8078
  function Element() {
7914
8079
  _classCallCheck$x(this, Element);
8080
+ _defineProperty$w(this, "x", void 0);
8081
+ _defineProperty$w(this, "y", void 0);
7915
8082
  _defineProperty$w(this, "active", false);
8083
+ _defineProperty$w(this, "options", void 0);
8084
+ _defineProperty$w(this, "$animations", void 0);
7916
8085
  }
7917
8086
  _createClass$x(Element, [{
7918
8087
  key: "tooltipPosition",
@@ -8064,6 +8233,9 @@
8064
8233
  var offsetFromEdge = function offsetFromEdge(scale, edge, offset) {
8065
8234
  return edge === 'top' || edge === 'left' ? scale[edge] + offset : scale[edge] - offset;
8066
8235
  };
8236
+ var getTicksLimit = function getTicksLimit(ticksLength, maxTicksLimit) {
8237
+ return Math.min(maxTicksLimit || ticksLength, ticksLength);
8238
+ };
8067
8239
  function sample(arr, numItems) {
8068
8240
  var result = [];
8069
8241
  var increment = arr.length / numItems;
@@ -8168,9 +8340,9 @@
8168
8340
  maxWidth = right - left;
8169
8341
  } else {
8170
8342
  if (isObject(position)) {
8171
- var positionAxisID1 = Object.keys(position)[0];
8172
- var value1 = position[positionAxisID1];
8173
- titleX = scales[positionAxisID1].getPixelForValue(value1) - width + offset;
8343
+ var _positionAxisID = Object.keys(position)[0];
8344
+ var _value = position[_positionAxisID];
8345
+ titleX = scales[_positionAxisID].getPixelForValue(_value) - width + offset;
8174
8346
  } else if (position === 'center') {
8175
8347
  titleX = (chartArea.left + chartArea.right) / 2 - width + offset;
8176
8348
  } else {
@@ -8515,7 +8687,7 @@
8515
8687
  value: function calculateLabelRotation() {
8516
8688
  var options = this.options;
8517
8689
  var tickOpts = options.ticks;
8518
- var numTicks = this.ticks.length;
8690
+ var numTicks = getTicksLimit(this.ticks.length, options.ticks.maxTicksLimit);
8519
8691
  var minRotation = tickOpts.minRotation || 0;
8520
8692
  var maxRotation = tickOpts.maxRotation;
8521
8693
  var labelRotation = minRotation;
@@ -8703,21 +8875,22 @@
8703
8875
  if (sampleSize < ticks.length) {
8704
8876
  ticks = sample(ticks, sampleSize);
8705
8877
  }
8706
- this._labelSizes = labelSizes = this._computeLabelSizes(ticks, ticks.length);
8878
+ this._labelSizes = labelSizes = this._computeLabelSizes(ticks, ticks.length, this.options.ticks.maxTicksLimit);
8707
8879
  }
8708
8880
  return labelSizes;
8709
8881
  }
8710
8882
  }, {
8711
8883
  key: "_computeLabelSizes",
8712
- value: function _computeLabelSizes(ticks, length) {
8884
+ value: function _computeLabelSizes(ticks, length, maxTicksLimit) {
8713
8885
  var ctx = this.ctx,
8714
8886
  caches = this._longestTextCache;
8715
8887
  var widths = [];
8716
8888
  var heights = [];
8889
+ var increment = Math.floor(length / getTicksLimit(length, maxTicksLimit));
8717
8890
  var widestLabelSize = 0;
8718
8891
  var highestLabelSize = 0;
8719
8892
  var i, j, jlen, label, tickFont, fontString, cache, lineHeight, width, height, nestedLabel;
8720
- for (i = 0; i < length; ++i) {
8893
+ for (i = 0; i < length; i += increment) {
8721
8894
  label = ticks[i].label;
8722
8895
  tickFont = this._resolveTickFontOptions(i);
8723
8896
  ctx.font = fontString = tickFont.string;
@@ -8906,9 +9079,9 @@
8906
9079
  if (position === 'center') {
8907
9080
  borderValue = alignBorderValue((chartArea.left + chartArea.right) / 2);
8908
9081
  } else if (isObject(position)) {
8909
- var positionAxisID1 = Object.keys(position)[0];
8910
- var value1 = position[positionAxisID1];
8911
- borderValue = alignBorderValue(this.chart.scales[positionAxisID1].getPixelForValue(value1));
9082
+ var _positionAxisID2 = Object.keys(position)[0];
9083
+ var _value2 = position[_positionAxisID2];
9084
+ borderValue = alignBorderValue(this.chart.scales[_positionAxisID2].getPixelForValue(_value2));
8912
9085
  }
8913
9086
  tx1 = borderValue - axisHalfWidth;
8914
9087
  tx2 = tx1 - tl;
@@ -8993,9 +9166,9 @@
8993
9166
  textAlign = ret.textAlign;
8994
9167
  x = ret.x;
8995
9168
  } else if (position === 'right') {
8996
- var ret1 = this._getYAxisLabelAlignment(tl);
8997
- textAlign = ret1.textAlign;
8998
- x = ret1.x;
9169
+ var _ret = this._getYAxisLabelAlignment(tl);
9170
+ textAlign = _ret.textAlign;
9171
+ x = _ret.x;
8999
9172
  } else if (axis === 'x') {
9000
9173
  if (position === 'center') {
9001
9174
  y = (chartArea.top + chartArea.bottom) / 2 + tickAndPadding;
@@ -9009,9 +9182,9 @@
9009
9182
  if (position === 'center') {
9010
9183
  x = (chartArea.left + chartArea.right) / 2 - tickAndPadding;
9011
9184
  } else if (isObject(position)) {
9012
- var positionAxisID1 = Object.keys(position)[0];
9013
- var value1 = position[positionAxisID1];
9014
- x = this.chart.scales[positionAxisID1].getPixelForValue(value1);
9185
+ var _positionAxisID3 = Object.keys(position)[0];
9186
+ var _value3 = position[_positionAxisID3];
9187
+ x = this.chart.scales[_positionAxisID3].getPixelForValue(_value3);
9015
9188
  }
9016
9189
  textAlign = this._getYAxisLabelAlignment(tl).textAlign;
9017
9190
  }
@@ -9840,8 +10013,8 @@
9840
10013
  plugins.push(registry.getPlugin(keys[i]));
9841
10014
  }
9842
10015
  var local = config.plugins || [];
9843
- for (var i1 = 0; i1 < local.length; i1++) {
9844
- var plugin = local[i1];
10016
+ for (var _i2 = 0; _i2 < local.length; _i2++) {
10017
+ var plugin = local[_i2];
9845
10018
  if (plugins.indexOf(plugin) === -1) {
9846
10019
  plugins.push(plugin);
9847
10020
  localIds[plugin.id] = true;
@@ -9922,6 +10095,11 @@
9922
10095
  function getDefaultScaleIDFromAxis(axis, indexAxis) {
9923
10096
  return axis === indexAxis ? '_index_' : '_value_';
9924
10097
  }
10098
+ function idMatchesAxis(id) {
10099
+ if (id === 'x' || id === 'y' || id === 'r') {
10100
+ return id;
10101
+ }
10102
+ }
9925
10103
  function axisFromPosition(position) {
9926
10104
  if (position === 'top' || position === 'bottom') {
9927
10105
  return 'x';
@@ -9930,15 +10108,39 @@
9930
10108
  return 'y';
9931
10109
  }
9932
10110
  }
9933
- function determineAxis(id, scaleOptions) {
9934
- if (id === 'x' || id === 'y' || id === 'r') {
10111
+ function determineAxis(id) {
10112
+ if (idMatchesAxis(id)) {
9935
10113
  return id;
9936
10114
  }
9937
- id = scaleOptions.axis || axisFromPosition(scaleOptions.position) || id.length > 1 && determineAxis(id[0].toLowerCase(), scaleOptions);
9938
- if (id) {
9939
- return id;
10115
+ for (var _len11 = arguments.length, scaleOptions = new Array(_len11 > 1 ? _len11 - 1 : 0), _key11 = 1; _key11 < _len11; _key11++) {
10116
+ scaleOptions[_key11 - 1] = arguments[_key11];
10117
+ }
10118
+ for (var _i3 = 0, _scaleOptions = scaleOptions; _i3 < _scaleOptions.length; _i3++) {
10119
+ var opts = _scaleOptions[_i3];
10120
+ var axis = opts.axis || axisFromPosition(opts.position) || id.length > 1 && idMatchesAxis(id[0].toLowerCase());
10121
+ if (axis) {
10122
+ return axis;
10123
+ }
10124
+ }
10125
+ throw new Error("Cannot determine type of '".concat(id, "' axis. Please provide 'axis' or 'position' option."));
10126
+ }
10127
+ function getAxisFromDataset(id, axis, dataset) {
10128
+ if (dataset[axis + 'AxisID'] === id) {
10129
+ return {
10130
+ axis: axis
10131
+ };
10132
+ }
10133
+ }
10134
+ function retrieveAxisFromDatasets(id, config) {
10135
+ if (config.data && config.data.datasets) {
10136
+ var boundDs = config.data.datasets.filter(function (d) {
10137
+ return d.xAxisID === id || d.yAxisID === id;
10138
+ });
10139
+ if (boundDs.length) {
10140
+ return getAxisFromDataset(id, 'x', boundDs[0]) || getAxisFromDataset(id, 'y', boundDs[0]);
10141
+ }
9940
10142
  }
9941
- throw new Error("Cannot determine type of '".concat(name, "' axis. Please provide 'axis' or 'position' option."));
10143
+ return {};
9942
10144
  }
9943
10145
  function mergeScaleConfig(config, options) {
9944
10146
  var chartDefaults = overrides[config.type] || {
@@ -9955,7 +10157,7 @@
9955
10157
  if (scaleConf._proxy) {
9956
10158
  return console.warn("Ignoring resolver passed as options for scale: ".concat(id));
9957
10159
  }
9958
- var axis = determineAxis(id, scaleConf);
10160
+ var axis = determineAxis(id, scaleConf, retrieveAxisFromDatasets(id, config), defaults.scales[scaleConf.type]);
9959
10161
  var defaultId = getDefaultScaleIDFromAxis(axis, chartIndexAxis);
9960
10162
  var defaultScaleOptions = chartDefaults.scales || {};
9961
10163
  scales[id] = mergeIf(Object.create(null), [{
@@ -10251,7 +10453,7 @@
10251
10453
  }
10252
10454
  return false;
10253
10455
  }
10254
- var version = "4.2.0";
10456
+ var version = "4.3.0";
10255
10457
  var KNOWN_POSITIONS = ['top', 'bottom', 'left', 'right', 'chartArea'];
10256
10458
  function positionIsHorizontal(position, axis) {
10257
10459
  return position === 'top' || position === 'bottom' || KNOWN_POSITIONS.indexOf(position) === -1 && axis === 'x';
@@ -10292,8 +10494,8 @@
10292
10494
  };
10293
10495
  function moveNumericKeys(obj, start, move) {
10294
10496
  var keys = Object.keys(obj);
10295
- for (var _i2 = 0, _keys = keys; _i2 < _keys.length; _i2++) {
10296
- var key = _keys[_i2];
10497
+ for (var _i4 = 0, _keys = keys; _i4 < _keys.length; _i4++) {
10498
+ var key = _keys[_i4];
10297
10499
  var intKey = +key;
10298
10500
  if (intKey >= start) {
10299
10501
  var value = obj[key];
@@ -10325,7 +10527,7 @@
10325
10527
  };
10326
10528
  }
10327
10529
  }
10328
- var Chart$1 = /*#__PURE__*/function () {
10530
+ var Chart = /*#__PURE__*/function () {
10329
10531
  function Chart(item, userConfig) {
10330
10532
  var _this12 = this;
10331
10533
  _classCallCheck$x(this, Chart);
@@ -10802,9 +11004,9 @@
10802
11004
  for (var i = 0, ilen = this.data.datasets.length; i < ilen; ++i) {
10803
11005
  this.getDatasetMeta(i).controller.configure();
10804
11006
  }
10805
- for (var i1 = 0, ilen1 = this.data.datasets.length; i1 < ilen1; ++i1) {
10806
- this._updateDataset(i1, isFunction(mode) ? mode({
10807
- datasetIndex: i1
11007
+ for (var _i5 = 0, _ilen = this.data.datasets.length; _i5 < _ilen; ++_i5) {
11008
+ this._updateDataset(_i5, isFunction(mode) ? mode({
11009
+ datasetIndex: _i5
10808
11010
  }) : mode);
10809
11011
  }
10810
11012
  this.notifyPlugins('afterDatasetsUpdate', {
@@ -11334,14 +11536,14 @@
11334
11536
  }]);
11335
11537
  return Chart;
11336
11538
  }();
11337
- _defineProperty$w(Chart$1, "defaults", defaults);
11338
- _defineProperty$w(Chart$1, "instances", instances);
11339
- _defineProperty$w(Chart$1, "overrides", overrides);
11340
- _defineProperty$w(Chart$1, "registry", registry);
11341
- _defineProperty$w(Chart$1, "version", version);
11342
- _defineProperty$w(Chart$1, "getChart", getChart);
11539
+ _defineProperty$w(Chart, "defaults", defaults);
11540
+ _defineProperty$w(Chart, "instances", instances);
11541
+ _defineProperty$w(Chart, "overrides", overrides);
11542
+ _defineProperty$w(Chart, "registry", registry);
11543
+ _defineProperty$w(Chart, "version", version);
11544
+ _defineProperty$w(Chart, "getChart", getChart);
11343
11545
  function invalidatePlugins() {
11344
- return each(Chart$1.instances, function (chart) {
11546
+ return each(Chart.instances, function (chart) {
11345
11547
  return chart._plugins.invalidate();
11346
11548
  });
11347
11549
  }
@@ -11470,8 +11672,8 @@
11470
11672
  ctx.lineTo(p4.x, p4.y);
11471
11673
  // The corner segment from point 4 to point 5
11472
11674
  if (innerEnd > 0) {
11473
- var pCenter1 = rThetaToXY(innerEndAdjustedRadius, innerEndAdjustedAngle, x, y);
11474
- ctx.arc(pCenter1.x, pCenter1.y, innerEnd, endAngle + HALF_PI, innerEndAdjustedAngle + Math.PI);
11675
+ var _pCenter = rThetaToXY(innerEndAdjustedRadius, innerEndAdjustedAngle, x, y);
11676
+ ctx.arc(_pCenter.x, _pCenter.y, innerEnd, endAngle + HALF_PI, innerEndAdjustedAngle + Math.PI);
11475
11677
  }
11476
11678
  // The inner arc from point 5 to point b to point 6
11477
11679
  var innerMidAdjustedAngle = (endAngle - innerEnd / innerRadius + (startAngle + innerStart / innerRadius)) / 2;
@@ -11479,16 +11681,16 @@
11479
11681
  ctx.arc(x, y, innerRadius, innerMidAdjustedAngle, startAngle + innerStart / innerRadius, true);
11480
11682
  // The corner segment from point 6 to point 7
11481
11683
  if (innerStart > 0) {
11482
- var pCenter2 = rThetaToXY(innerStartAdjustedRadius, innerStartAdjustedAngle, x, y);
11483
- ctx.arc(pCenter2.x, pCenter2.y, innerStart, innerStartAdjustedAngle + Math.PI, startAngle - HALF_PI);
11684
+ var _pCenter2 = rThetaToXY(innerStartAdjustedRadius, innerStartAdjustedAngle, x, y);
11685
+ ctx.arc(_pCenter2.x, _pCenter2.y, innerStart, innerStartAdjustedAngle + Math.PI, startAngle - HALF_PI);
11484
11686
  }
11485
11687
  // The line from point 7 to point 8
11486
11688
  var p8 = rThetaToXY(outerStartAdjustedRadius, startAngle, x, y);
11487
11689
  ctx.lineTo(p8.x, p8.y);
11488
11690
  // The corner segment from point 8 to point 1
11489
11691
  if (outerStart > 0) {
11490
- var pCenter3 = rThetaToXY(outerStartAdjustedRadius, outerStartAdjustedAngle, x, y);
11491
- ctx.arc(pCenter3.x, pCenter3.y, outerStart, startAngle - HALF_PI, outerStartAdjustedAngle);
11692
+ var _pCenter3 = rThetaToXY(outerStartAdjustedRadius, outerStartAdjustedAngle, x, y);
11693
+ ctx.arc(_pCenter3.x, _pCenter3.y, outerStart, startAngle - HALF_PI, outerStartAdjustedAngle);
11492
11694
  }
11493
11695
  } else {
11494
11696
  ctx.moveTo(x, y);
@@ -11525,11 +11727,15 @@
11525
11727
  circumference = element.circumference,
11526
11728
  options = element.options;
11527
11729
  var borderWidth = options.borderWidth,
11528
- borderJoinStyle = options.borderJoinStyle;
11730
+ borderJoinStyle = options.borderJoinStyle,
11731
+ borderDash = options.borderDash,
11732
+ borderDashOffset = options.borderDashOffset;
11529
11733
  var inner = options.borderAlign === 'inner';
11530
11734
  if (!borderWidth) {
11531
11735
  return;
11532
11736
  }
11737
+ ctx.setLineDash(borderDash || []);
11738
+ ctx.lineDashOffset = borderDashOffset;
11533
11739
  if (inner) {
11534
11740
  ctx.lineWidth = borderWidth * 2;
11535
11741
  ctx.lineJoin = borderJoinStyle || 'round';
@@ -11562,6 +11768,13 @@
11562
11768
  var _this23;
11563
11769
  _classCallCheck$x(this, ArcElement);
11564
11770
  _this23 = _super12.call(this);
11771
+ _defineProperty$w(_assertThisInitialized$w(_this23), "circumference", void 0);
11772
+ _defineProperty$w(_assertThisInitialized$w(_this23), "endAngle", void 0);
11773
+ _defineProperty$w(_assertThisInitialized$w(_this23), "fullCircles", void 0);
11774
+ _defineProperty$w(_assertThisInitialized$w(_this23), "innerRadius", void 0);
11775
+ _defineProperty$w(_assertThisInitialized$w(_this23), "outerRadius", void 0);
11776
+ _defineProperty$w(_assertThisInitialized$w(_this23), "pixelMargin", void 0);
11777
+ _defineProperty$w(_assertThisInitialized$w(_this23), "startAngle", void 0);
11565
11778
  _this23.options = undefined;
11566
11779
  _this23.circumference = undefined;
11567
11780
  _this23.startAngle = undefined;
@@ -11591,7 +11804,7 @@
11591
11804
  innerRadius = _this$getProps2.innerRadius,
11592
11805
  outerRadius = _this$getProps2.outerRadius,
11593
11806
  circumference = _this$getProps2.circumference;
11594
- var rAdjust = this.options.spacing / 2;
11807
+ var rAdjust = (this.options.spacing + this.options.borderWidth) / 2;
11595
11808
  var _circumference = valueOrDefault(circumference, endAngle - startAngle);
11596
11809
  var betweenAngles = _circumference >= TAU || _angleBetween(angle, startAngle, endAngle);
11597
11810
  var withinRadius = _isBetween(distance, innerRadius + rAdjust, outerRadius + rAdjust);
@@ -11600,7 +11813,7 @@
11600
11813
  }, {
11601
11814
  key: "getCenterPoint",
11602
11815
  value: function getCenterPoint(useFinalPosition) {
11603
- var _this$getProps3 = this.getProps(['x', 'y', 'startAngle', 'endAngle', 'innerRadius', 'outerRadius', 'circumference'], useFinalPosition),
11816
+ var _this$getProps3 = this.getProps(['x', 'y', 'startAngle', 'endAngle', 'innerRadius', 'outerRadius'], useFinalPosition),
11604
11817
  x = _this$getProps3.x,
11605
11818
  y = _this$getProps3.y,
11606
11819
  startAngle = _this$getProps3.startAngle,
@@ -11653,6 +11866,8 @@
11653
11866
  _defineProperty$w(ArcElement, "defaults", {
11654
11867
  borderAlign: 'center',
11655
11868
  borderColor: '#fff',
11869
+ borderDash: [],
11870
+ borderDashOffset: 0,
11656
11871
  borderJoinStyle: undefined,
11657
11872
  borderRadius: 0,
11658
11873
  borderWidth: 2,
@@ -11664,6 +11879,12 @@
11664
11879
  _defineProperty$w(ArcElement, "defaultRoutes", {
11665
11880
  backgroundColor: 'backgroundColor'
11666
11881
  });
11882
+ _defineProperty$w(ArcElement, "descriptors", {
11883
+ _scriptable: true,
11884
+ _indexable: function _indexable(name) {
11885
+ return name !== 'borderDash';
11886
+ }
11887
+ });
11667
11888
  function setStyle(ctx, options) {
11668
11889
  var style = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : options;
11669
11890
  ctx.lineCap = valueOrDefault(style.borderCapStyle, options.borderCapStyle);
@@ -12028,18 +12249,13 @@
12028
12249
  var PointElement = /*#__PURE__*/function (_Element4) {
12029
12250
  _inherits$w(PointElement, _Element4);
12030
12251
  var _super14 = _createSuper$w(PointElement);
12031
- /**
12032
- * @type {any}
12033
- */
12034
-
12035
- /**
12036
- * @type {any}
12037
- */
12038
-
12039
12252
  function PointElement(cfg) {
12040
12253
  var _this25;
12041
12254
  _classCallCheck$x(this, PointElement);
12042
12255
  _this25 = _super14.call(this);
12256
+ _defineProperty$w(_assertThisInitialized$w(_this25), "parsed", void 0);
12257
+ _defineProperty$w(_assertThisInitialized$w(_this25), "skip", void 0);
12258
+ _defineProperty$w(_assertThisInitialized$w(_this25), "stop", void 0);
12043
12259
  _this25.options = undefined;
12044
12260
  _this25.parsed = undefined;
12045
12261
  _this25.skip = undefined;
@@ -12111,6 +12327,9 @@
12111
12327
  return PointElement;
12112
12328
  }(Element);
12113
12329
  _defineProperty$w(PointElement, "id", 'point');
12330
+ /**
12331
+ * @type {any}
12332
+ */
12114
12333
  _defineProperty$w(PointElement, "defaults", {
12115
12334
  borderWidth: 1,
12116
12335
  hitRadius: 1,
@@ -12120,6 +12339,9 @@
12120
12339
  radius: 3,
12121
12340
  rotation: 0
12122
12341
  });
12342
+ /**
12343
+ * @type {any}
12344
+ */
12123
12345
  _defineProperty$w(PointElement, "defaultRoutes", {
12124
12346
  backgroundColor: 'backgroundColor',
12125
12347
  borderColor: 'borderColor'
@@ -12331,9 +12553,9 @@
12331
12553
  var elements = /*#__PURE__*/Object.freeze({
12332
12554
  __proto__: null,
12333
12555
  ArcElement: ArcElement,
12556
+ BarElement: BarElement,
12334
12557
  LineElement: LineElement,
12335
- PointElement: PointElement,
12336
- BarElement: BarElement
12558
+ PointElement: PointElement
12337
12559
  });
12338
12560
  var BORDER_COLORS = ['rgb(54, 162, 235)', 'rgb(255, 99, 132)', 'rgb(255, 159, 64)', 'rgb(255, 205, 86)', 'rgb(75, 192, 192)', 'rgb(153, 102, 255)', 'rgb(201, 203, 207)' // grey
12339
12561
  ];
@@ -12512,6 +12734,9 @@
12512
12734
  delete dataset._decimated;
12513
12735
  delete dataset._data;
12514
12736
  Object.defineProperty(dataset, 'data', {
12737
+ configurable: true,
12738
+ enumerable: true,
12739
+ writable: true,
12515
12740
  value: data
12516
12741
  });
12517
12742
  }
@@ -13517,15 +13742,15 @@
13517
13742
  _step24;
13518
13743
  try {
13519
13744
  for (_iterator24.s(); !(_step24 = _iterator24.n()).done;) {
13520
- var hitbox1 = _step24.value;
13521
- if (hitbox1.col !== col) {
13522
- col = hitbox1.col;
13745
+ var _hitbox = _step24.value;
13746
+ if (_hitbox.col !== col) {
13747
+ col = _hitbox.col;
13523
13748
  top = _alignStartEnd(align, this.top + titleHeight + padding, this.bottom - this.columnSizes[col].height);
13524
13749
  }
13525
- hitbox1.top = top;
13526
- hitbox1.left += this.left + padding;
13527
- hitbox1.left = rtlHelper.leftForLtr(rtlHelper.x(hitbox1.left), hitbox1.width);
13528
- top += hitbox1.height + padding;
13750
+ _hitbox.top = top;
13751
+ _hitbox.left += this.left + padding;
13752
+ _hitbox.left = rtlHelper.leftForLtr(rtlHelper.x(_hitbox.left), _hitbox.width);
13753
+ top += _hitbox.height + padding;
13529
13754
  }
13530
13755
  } catch (err) {
13531
13756
  _iterator24.e(err);
@@ -14744,11 +14969,10 @@
14744
14969
  }, {
14745
14970
  key: "_drawColorBox",
14746
14971
  value: function _drawColorBox(ctx, pt, i, rtlHelper, options) {
14747
- var labelColors = this.labelColors[i];
14972
+ var labelColor = this.labelColors[i];
14748
14973
  var labelPointStyle = this.labelPointStyles[i];
14749
14974
  var boxHeight = options.boxHeight,
14750
- boxWidth = options.boxWidth,
14751
- boxPadding = options.boxPadding;
14975
+ boxWidth = options.boxWidth;
14752
14976
  var bodyFont = toFont(options.bodyFont);
14753
14977
  var colorX = getAlignedX(this, 'left', options);
14754
14978
  var rtlColorX = rtlHelper.x(colorX);
@@ -14766,17 +14990,17 @@
14766
14990
  ctx.strokeStyle = options.multiKeyBackground;
14767
14991
  ctx.fillStyle = options.multiKeyBackground;
14768
14992
  drawPoint(ctx, drawOptions, centerX, centerY);
14769
- ctx.strokeStyle = labelColors.borderColor;
14770
- ctx.fillStyle = labelColors.backgroundColor;
14993
+ ctx.strokeStyle = labelColor.borderColor;
14994
+ ctx.fillStyle = labelColor.backgroundColor;
14771
14995
  drawPoint(ctx, drawOptions, centerX, centerY);
14772
14996
  } else {
14773
- ctx.lineWidth = isObject(labelColors.borderWidth) ? Math.max.apply(Math, _toConsumableArray(Object.values(labelColors.borderWidth))) : labelColors.borderWidth || 1;
14774
- ctx.strokeStyle = labelColors.borderColor;
14775
- ctx.setLineDash(labelColors.borderDash || []);
14776
- ctx.lineDashOffset = labelColors.borderDashOffset || 0;
14777
- var outerX = rtlHelper.leftForLtr(rtlColorX, boxWidth - boxPadding);
14778
- var innerX = rtlHelper.leftForLtr(rtlHelper.xPlus(rtlColorX, 1), boxWidth - boxPadding - 2);
14779
- var borderRadius = toTRBLCorners(labelColors.borderRadius);
14997
+ ctx.lineWidth = isObject(labelColor.borderWidth) ? Math.max.apply(Math, _toConsumableArray(Object.values(labelColor.borderWidth))) : labelColor.borderWidth || 1;
14998
+ ctx.strokeStyle = labelColor.borderColor;
14999
+ ctx.setLineDash(labelColor.borderDash || []);
15000
+ ctx.lineDashOffset = labelColor.borderDashOffset || 0;
15001
+ var outerX = rtlHelper.leftForLtr(rtlColorX, boxWidth);
15002
+ var innerX = rtlHelper.leftForLtr(rtlHelper.xPlus(rtlColorX, 1), boxWidth - 2);
15003
+ var borderRadius = toTRBLCorners(labelColor.borderRadius);
14780
15004
  if (Object.values(borderRadius).some(function (v) {
14781
15005
  return v !== 0;
14782
15006
  })) {
@@ -14791,7 +15015,7 @@
14791
15015
  });
14792
15016
  ctx.fill();
14793
15017
  ctx.stroke();
14794
- ctx.fillStyle = labelColors.backgroundColor;
15018
+ ctx.fillStyle = labelColor.backgroundColor;
14795
15019
  ctx.beginPath();
14796
15020
  addRoundedRectPath(ctx, {
14797
15021
  x: innerX,
@@ -14805,7 +15029,7 @@
14805
15029
  ctx.fillStyle = options.multiKeyBackground;
14806
15030
  ctx.fillRect(outerX, colorY, boxWidth, boxHeight);
14807
15031
  ctx.strokeRect(outerX, colorY, boxWidth, boxHeight);
14808
- ctx.fillStyle = labelColors.backgroundColor;
15032
+ ctx.fillStyle = labelColor.backgroundColor;
14809
15033
  ctx.fillRect(innerX, colorY + 1, boxWidth - 2, boxHeight - 2);
14810
15034
  }
14811
15035
  }
@@ -15456,8 +15680,12 @@
15456
15680
  }
15457
15681
  }
15458
15682
  for (; j < numSpaces; ++j) {
15683
+ var tickValue = Math.round((niceMin + j * spacing) * factor) / factor;
15684
+ if (maxDefined && tickValue > max) {
15685
+ break;
15686
+ }
15459
15687
  ticks.push({
15460
- value: Math.round((niceMin + j * spacing) * factor) / factor
15688
+ value: tickValue
15461
15689
  });
15462
15690
  }
15463
15691
  if (maxDefined && includeBounds && niceMax !== max) {
@@ -15957,29 +16185,74 @@
15957
16185
  limits.b = Math.max(limits.b, orig.b + y);
15958
16186
  }
15959
16187
  }
16188
+ function createPointLabelItem(scale, index, itemOpts) {
16189
+ var outerDistance = scale.drawingArea;
16190
+ var extra = itemOpts.extra,
16191
+ additionalAngle = itemOpts.additionalAngle,
16192
+ padding = itemOpts.padding,
16193
+ size = itemOpts.size;
16194
+ var pointLabelPosition = scale.getPointPosition(index, outerDistance + extra + padding, additionalAngle);
16195
+ var angle = Math.round(toDegrees(_normalizeAngle(pointLabelPosition.angle + HALF_PI)));
16196
+ var y = yForAngle(pointLabelPosition.y, size.h, angle);
16197
+ var textAlign = getTextAlignForAngle(angle);
16198
+ var left = leftForTextAlign(pointLabelPosition.x, size.w, textAlign);
16199
+ return {
16200
+ visible: true,
16201
+ x: pointLabelPosition.x,
16202
+ y: y,
16203
+ textAlign: textAlign,
16204
+ left: left,
16205
+ top: y,
16206
+ right: left + size.w,
16207
+ bottom: y + size.h
16208
+ };
16209
+ }
16210
+ function isNotOverlapped(item, area) {
16211
+ if (!area) {
16212
+ return true;
16213
+ }
16214
+ var left = item.left,
16215
+ top = item.top,
16216
+ right = item.right,
16217
+ bottom = item.bottom;
16218
+ var apexesInArea = _isPointInArea({
16219
+ x: left,
16220
+ y: top
16221
+ }, area) || _isPointInArea({
16222
+ x: left,
16223
+ y: bottom
16224
+ }, area) || _isPointInArea({
16225
+ x: right,
16226
+ y: top
16227
+ }, area) || _isPointInArea({
16228
+ x: right,
16229
+ y: bottom
16230
+ }, area);
16231
+ return !apexesInArea;
16232
+ }
15960
16233
  function buildPointLabelItems(scale, labelSizes, padding) {
15961
16234
  var items = [];
15962
16235
  var valueCount = scale._pointLabels.length;
15963
16236
  var opts = scale.options;
15964
- var extra = getTickBackdropHeight(opts) / 2;
15965
- var outerDistance = scale.drawingArea;
15966
- var additionalAngle = opts.pointLabels.centerPointLabels ? PI / valueCount : 0;
16237
+ var _opts$pointLabels = opts.pointLabels,
16238
+ centerPointLabels = _opts$pointLabels.centerPointLabels,
16239
+ display = _opts$pointLabels.display;
16240
+ var itemOpts = {
16241
+ extra: getTickBackdropHeight(opts) / 2,
16242
+ additionalAngle: centerPointLabels ? PI / valueCount : 0
16243
+ };
16244
+ var area;
15967
16245
  for (var i = 0; i < valueCount; i++) {
15968
- var pointLabelPosition = scale.getPointPosition(i, outerDistance + extra + padding[i], additionalAngle);
15969
- var angle = Math.round(toDegrees(_normalizeAngle(pointLabelPosition.angle + HALF_PI)));
15970
- var size = labelSizes[i];
15971
- var y = yForAngle(pointLabelPosition.y, size.h, angle);
15972
- var textAlign = getTextAlignForAngle(angle);
15973
- var left = leftForTextAlign(pointLabelPosition.x, size.w, textAlign);
15974
- items.push({
15975
- x: pointLabelPosition.x,
15976
- y: y,
15977
- textAlign: textAlign,
15978
- left: left,
15979
- top: y,
15980
- right: left + size.w,
15981
- bottom: y + size.h
15982
- });
16246
+ itemOpts.padding = padding[i];
16247
+ itemOpts.size = labelSizes[i];
16248
+ var item = createPointLabelItem(scale, i, itemOpts);
16249
+ items.push(item);
16250
+ if (display === 'auto') {
16251
+ item.visible = isNotOverlapped(item, area);
16252
+ if (item.visible) {
16253
+ area = item;
16254
+ }
16255
+ }
15983
16256
  }
15984
16257
  return items;
15985
16258
  }
@@ -16007,45 +16280,51 @@
16007
16280
  }
16008
16281
  return y;
16009
16282
  }
16283
+ function drawPointLabelBox(ctx, opts, item) {
16284
+ var left = item.left,
16285
+ top = item.top,
16286
+ right = item.right,
16287
+ bottom = item.bottom;
16288
+ var backdropColor = opts.backdropColor;
16289
+ if (!isNullOrUndef(backdropColor)) {
16290
+ var borderRadius = toTRBLCorners(opts.borderRadius);
16291
+ var padding = toPadding(opts.backdropPadding);
16292
+ ctx.fillStyle = backdropColor;
16293
+ var backdropLeft = left - padding.left;
16294
+ var backdropTop = top - padding.top;
16295
+ var backdropWidth = right - left + padding.width;
16296
+ var backdropHeight = bottom - top + padding.height;
16297
+ if (Object.values(borderRadius).some(function (v) {
16298
+ return v !== 0;
16299
+ })) {
16300
+ ctx.beginPath();
16301
+ addRoundedRectPath(ctx, {
16302
+ x: backdropLeft,
16303
+ y: backdropTop,
16304
+ w: backdropWidth,
16305
+ h: backdropHeight,
16306
+ radius: borderRadius
16307
+ });
16308
+ ctx.fill();
16309
+ } else {
16310
+ ctx.fillRect(backdropLeft, backdropTop, backdropWidth, backdropHeight);
16311
+ }
16312
+ }
16313
+ }
16010
16314
  function drawPointLabels(scale, labelCount) {
16011
16315
  var ctx = scale.ctx,
16012
16316
  pointLabels = scale.options.pointLabels;
16013
16317
  for (var i = labelCount - 1; i >= 0; i--) {
16318
+ var item = scale._pointLabelItems[i];
16319
+ if (!item.visible) {
16320
+ continue;
16321
+ }
16014
16322
  var optsAtIndex = pointLabels.setContext(scale.getPointLabelContext(i));
16323
+ drawPointLabelBox(ctx, optsAtIndex, item);
16015
16324
  var plFont = toFont(optsAtIndex.font);
16016
- var _scale$_pointLabelIte = scale._pointLabelItems[i],
16017
- x = _scale$_pointLabelIte.x,
16018
- y = _scale$_pointLabelIte.y,
16019
- textAlign = _scale$_pointLabelIte.textAlign,
16020
- left = _scale$_pointLabelIte.left,
16021
- top = _scale$_pointLabelIte.top,
16022
- right = _scale$_pointLabelIte.right,
16023
- bottom = _scale$_pointLabelIte.bottom;
16024
- var backdropColor = optsAtIndex.backdropColor;
16025
- if (!isNullOrUndef(backdropColor)) {
16026
- var borderRadius = toTRBLCorners(optsAtIndex.borderRadius);
16027
- var padding = toPadding(optsAtIndex.backdropPadding);
16028
- ctx.fillStyle = backdropColor;
16029
- var backdropLeft = left - padding.left;
16030
- var backdropTop = top - padding.top;
16031
- var backdropWidth = right - left + padding.width;
16032
- var backdropHeight = bottom - top + padding.height;
16033
- if (Object.values(borderRadius).some(function (v) {
16034
- return v !== 0;
16035
- })) {
16036
- ctx.beginPath();
16037
- addRoundedRectPath(ctx, {
16038
- x: backdropLeft,
16039
- y: backdropTop,
16040
- w: backdropWidth,
16041
- h: backdropHeight,
16042
- radius: borderRadius
16043
- });
16044
- ctx.fill();
16045
- } else {
16046
- ctx.fillRect(backdropLeft, backdropTop, backdropWidth, backdropHeight);
16047
- }
16048
- }
16325
+ var x = item.x,
16326
+ y = item.y,
16327
+ textAlign = item.textAlign;
16049
16328
  renderText(ctx, scale._pointLabels[i], x, y + plFont.lineHeight / 2, plFont, {
16050
16329
  color: optsAtIndex.color,
16051
16330
  textAlign: textAlign,
@@ -17003,8 +17282,7 @@
17003
17282
  });
17004
17283
  var registerables = [controllers, elements, plugins, scales];
17005
17284
 
17006
- Chart$1.register.apply(Chart$1, _toConsumableArray(registerables));
17007
- var Chart = Chart$1;
17285
+ Chart.register.apply(Chart, _toConsumableArray(registerables));
17008
17286
 
17009
17287
  var helpers = /*#__PURE__*/Object.freeze({
17010
17288
  __proto__: null,