SolidGaugeComposition.js 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. /* *
  2. *
  3. * Solid angular gauge module
  4. *
  5. * (c) 2010-2021 Torstein Honsi
  6. *
  7. * License: www.highcharts.com/license
  8. *
  9. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  10. *
  11. * */
  12. 'use strict';
  13. import H from '../../Core/Globals.js';
  14. var Renderer = H.Renderer;
  15. import U from '../../Core/Utilities.js';
  16. var wrap = U.wrap;
  17. /**
  18. * Additional options, depending on the actual symbol drawn.
  19. *
  20. * @interface Highcharts.SymbolOptionsObject
  21. */ /**
  22. * Whether to draw rounded edges.
  23. * @name Highcharts.SymbolOptionsObject#rounded
  24. * @type {boolean|undefined}
  25. */
  26. /**
  27. * Symbol definition of an arc with round edges.
  28. *
  29. * @private
  30. * @function Highcharts.Renderer#symbols.arc
  31. *
  32. * @param {number} x
  33. * The X coordinate for the top left position.
  34. *
  35. * @param {number} y
  36. * The Y coordinate for the top left position.
  37. *
  38. * @param {number} w
  39. * The pixel width.
  40. *
  41. * @param {number} h
  42. * The pixel height.
  43. *
  44. * @param {Highcharts.SymbolOptionsObject} [options]
  45. * Additional options, depending on the actual symbol drawn.
  46. *
  47. * @return {Highcharts.SVGPathArray}
  48. * Path of the created arc.
  49. */
  50. wrap(Renderer.prototype.symbols, 'arc', function (proceed, x, y, w, h, options) {
  51. var arc = proceed, path = arc(x, y, w, h, options);
  52. if (options.rounded) {
  53. var r = options.r || w, smallR = (r - (options.innerR || 0)) / 2, outerArcStart = path[0], innerArcStart = path[2];
  54. if (outerArcStart[0] === 'M' && innerArcStart[0] === 'L') {
  55. var x1 = outerArcStart[1], y1 = outerArcStart[2], x2 = innerArcStart[1], y2 = innerArcStart[2], roundStart = ['A', smallR, smallR, 0, 1, 1, x1, y1], roundEnd = ['A', smallR, smallR, 0, 1, 1, x2, y2];
  56. // Replace the line segment and the last close segment
  57. path[2] = roundEnd;
  58. path[4] = roundStart;
  59. }
  60. }
  61. return path;
  62. });