tiling.funnel.js 995 B

123456789101112131415161718192021222324252627
  1. /**
  2. * DevExtreme (viz/funnel/tiling.funnel.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 CENTER = .5;
  11. module.exports = {
  12. getFigures: function(data) {
  13. var height = 1 / data.length;
  14. return data.map(function(value, index, array) {
  15. var nextValue = array[index + 1] ? array[index + 1] : array[index];
  16. return [CENTER - value / 2, height * index, CENTER + value / 2, height * index, CENTER + nextValue / 2, height * (index + 1), CENTER - nextValue / 2, height * (index + 1)]
  17. })
  18. },
  19. normalizeValues: function(items) {
  20. var max = items.reduce(function(max, item) {
  21. return Math.max(item.value, max)
  22. }, items[0] && items[0].value || 0);
  23. return items.map(function(item) {
  24. return item.value / max
  25. })
  26. }
  27. };