polar_chart.js 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. /**
  2. * DevExtreme (viz/polar_chart.js)
  3. * Version: 19.1.16
  4. * Build date: Tue Oct 18 2022
  5. *
  6. * Copyright (c) 2012 - 2022 Developer Express Inc. ALL RIGHTS RESERVED
  7. * Read about DevExtreme licensing here: https://js.devexpress.com/Licensing/
  8. */
  9. "use strict";
  10. var _noop = require("../core/utils/common").noop;
  11. var registerComponent = require("../core/component_registrator");
  12. var extend = require("../core/utils/extend").extend;
  13. var vizUtils = require("./core/utils");
  14. var AdvancedChart = require("./chart_components/advanced_chart").AdvancedChart;
  15. var DEFAULT_PANE_NAME = "default";
  16. var dxPolarChart = AdvancedChart.inherit({
  17. _themeSection: "polar",
  18. _createPanes: function() {
  19. return [{
  20. name: DEFAULT_PANE_NAME
  21. }]
  22. },
  23. _checkPaneName: function() {
  24. return true
  25. },
  26. _getAxisRenderingOptions: function(typeSelector) {
  27. var isArgumentAxis = "argumentAxis" === typeSelector;
  28. var type = isArgumentAxis ? "circular" : "linear";
  29. var useSpiderWeb = this.option("useSpiderWeb");
  30. if (useSpiderWeb) {
  31. type += "Spider"
  32. }
  33. return {
  34. axisType: "polarAxes",
  35. drawingType: type
  36. }
  37. },
  38. _prepareAxisOptions: function(typeSelector, axisOptions) {
  39. var isArgumentAxis = "argumentAxis" === typeSelector;
  40. var themeManager = this._themeManager;
  41. var axisUserOptions = this.option("argumentAxis");
  42. var argumentAxisOptions = themeManager.getOptions("argumentAxis", axisUserOptions) || {};
  43. var startAngle = isFinite(argumentAxisOptions.startAngle) ? vizUtils.normalizeAngle(argumentAxisOptions.startAngle) : 0;
  44. return {
  45. type: this.option("useSpiderWeb") && isArgumentAxis ? "discrete" : axisOptions.type,
  46. isHorizontal: true,
  47. showCustomBoundaryTicks: isArgumentAxis,
  48. startAngle: startAngle,
  49. endAngle: startAngle + 360
  50. }
  51. },
  52. _optionChangesMap: {
  53. useSpiderWeb: "AXES_AND_PANES"
  54. },
  55. _getExtraOptions: function() {
  56. return {
  57. spiderWidget: this.option("useSpiderWeb")
  58. }
  59. },
  60. _prepareToRender: function() {
  61. this._appendAxesGroups();
  62. return {}
  63. },
  64. _calcCanvas: function() {
  65. var canvas = extend({}, this._canvas);
  66. var argumentAxis = this.getArgumentAxis();
  67. var margins = argumentAxis.getMargins();
  68. Object.keys(margins).forEach(function(margin) {
  69. return canvas[margin] = canvas["original".concat(margin[0].toUpperCase()).concat(margin.slice(1))] + margins[margin]
  70. });
  71. return canvas
  72. },
  73. _renderAxes: function(drawOptions) {
  74. var that = this;
  75. var valueAxis = that._getValueAxis();
  76. var argumentAxis = that.getArgumentAxis();
  77. argumentAxis.draw(that._canvas);
  78. valueAxis.setSpiderTicks(argumentAxis.getSpiderTicks());
  79. var canvas = that._calcCanvas();
  80. argumentAxis.updateSize(canvas);
  81. valueAxis.draw(canvas);
  82. return canvas
  83. },
  84. _getValueAxis: function() {
  85. return this._valueAxes[0]
  86. },
  87. _shrinkAxes: function(sizeStorage) {
  88. var valueAxis = this._getValueAxis();
  89. var argumentAxis = this.getArgumentAxis();
  90. if (sizeStorage && (sizeStorage.width || sizeStorage.height)) {
  91. argumentAxis.hideOuterElements();
  92. var canvas = this._calcCanvas();
  93. argumentAxis.updateSize(canvas);
  94. valueAxis.updateSize(canvas)
  95. }
  96. },
  97. checkForMoreSpaceForPanesCanvas: function() {
  98. return this.layoutManager.needMoreSpaceForPanesCanvas([{
  99. canvas: this.getArgumentAxis().getCanvas()
  100. }], this._isRotated())
  101. },
  102. _getLayoutTargets: function() {
  103. return [{
  104. canvas: this._canvas
  105. }]
  106. },
  107. _getSeriesForPane: function() {
  108. return this.series
  109. },
  110. _applyExtraSettings: _noop,
  111. _applyPointMarkersAutoHiding: _noop,
  112. _createScrollBar: _noop,
  113. _applyClipRects: _noop,
  114. _isRotated: _noop,
  115. _getCrosshairOptions: _noop,
  116. _isLegendInside: _noop
  117. });
  118. registerComponent("dxPolarChart", dxPolarChart);
  119. module.exports = dxPolarChart;
  120. module.exports.default = module.exports;