range_view.js 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. /**
  2. * DevExtreme (viz/range_selector/range_view.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. function drawSeriesView(root, seriesDataSource, canvas, isAnimationEnabled) {
  11. var seriesList = seriesDataSource.getSeries();
  12. if (!seriesList.length) {
  13. return
  14. }
  15. var valueAxis = seriesList[0].getValueAxis();
  16. valueAxis.updateCanvas({
  17. top: canvas.top,
  18. bottom: 0,
  19. height: canvas.height + canvas.top
  20. });
  21. seriesDataSource.adjustSeriesDimensions();
  22. var valueRange = seriesDataSource.getBoundRange().val;
  23. valueRange.sortCategories(valueAxis.getCategoriesSorter());
  24. valueAxis.setBusinessRange(valueRange);
  25. seriesList.forEach(function(series) {
  26. series._extGroups.seriesGroup = series._extGroups.labelsGroup = root;
  27. series.draw(isAnimationEnabled)
  28. })
  29. }
  30. function merge(a, b) {
  31. return void 0 !== a ? a : b
  32. }
  33. function RangeView(params) {
  34. this._params = params;
  35. this._clipRect = params.renderer.clipRect();
  36. params.root.attr({
  37. "clip-path": this._clipRect.id
  38. })
  39. }
  40. RangeView.prototype = {
  41. constructor: RangeView,
  42. update: function(backgroundOption, backgroundTheme, canvas, isCompactMode, isAnimationEnabled, seriesDataSource) {
  43. var renderer = this._params.renderer;
  44. var root = this._params.root;
  45. var canvasWidth = canvas.width - canvas.left;
  46. var seriesGroup;
  47. backgroundOption = backgroundOption || {};
  48. root.clear();
  49. this._clipRect.attr({
  50. x: canvas.left,
  51. y: canvas.top,
  52. width: canvasWidth,
  53. height: canvas.height
  54. });
  55. if (!isCompactMode) {
  56. if (merge(backgroundOption.visible, backgroundTheme.visible)) {
  57. if (backgroundOption.color) {
  58. renderer.rect(canvas.left, canvas.top, canvasWidth + 1, canvas.height).attr({
  59. fill: merge(backgroundOption.color, backgroundTheme.color),
  60. "class": "dx-range-selector-background"
  61. }).append(root)
  62. }
  63. if (backgroundOption.image && backgroundOption.image.url) {
  64. renderer.image(canvas.left, canvas.top, canvasWidth + 1, canvas.height, backgroundOption.image.url, merge(backgroundOption.image.location, backgroundTheme.image.location)).append(root)
  65. }
  66. }
  67. if (seriesDataSource && seriesDataSource.isShowChart()) {
  68. seriesGroup = renderer.g().attr({
  69. "class": "dxrs-series-group"
  70. }).append(root);
  71. drawSeriesView(seriesGroup, seriesDataSource, canvas, isAnimationEnabled)
  72. }
  73. }
  74. }
  75. };
  76. exports.RangeView = RangeView;