v1.php 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. <?php
  2. /**
  3. * The treemap widget class file of zin module of ZenTaoPMS.
  4. *
  5. * @copyright Copyright 2009-2023 禅道软件(青岛)有限公司(ZenTao Software (Qingdao) Co., Ltd. www.zentao.net)
  6. * @license ZPL(https://zpl.pub/page/zplv12.html) or AGPL(https://www.gnu.org/licenses/agpl-3.0.en.html)
  7. * @author sunhao<sunhao@easycorp.ltd>
  8. * @package zin
  9. * @link http://www.zentao.net
  10. */
  11. namespace zin;
  12. /**
  13. * 组织结构图(treemap)部件。
  14. * The treemap widget class.
  15. */
  16. class treemap extends wg
  17. {
  18. /**
  19. * @var mixed[]
  20. */
  21. protected static $defineProps = array
  22. (
  23. 'width?: string|number="100%"', // 宽度。
  24. 'height?: string|number="300px"', // 高度。
  25. 'data?: array', // 树形结构数据。
  26. 'rowSpace?: number', // 节点层级之间的间距。
  27. 'nodeSpace?: number', // 同一层级相邻节点间的间距。
  28. 'foldable?: bool', // 是否可以折叠子节点。
  29. 'clickNodeToFold?: bool', // 是否允许直接点击节点折叠子节点。
  30. 'sort?: bool', // 是否启用排序。
  31. 'cableWidth?: number', // 连接线宽度。
  32. 'cableColor?: string', // 连接线颜色。
  33. 'cableStyle?: string', // 连接线样式。
  34. 'listenNodeResize?: bool', // 监听节点尺寸变化。
  35. 'tooltip?: array', // 工具提示选项。
  36. 'nodeStyle?: array', // 定义节点的默认样式。
  37. 'nodeTemplate?: string', // 节点元素模板。
  38. 'onNodeClick?: function', // 节点元素模板。
  39. 'afterDrawLines?: function', // 节点元素模板。
  40. 'afterRender?: function', // 节点元素模板。
  41. 'onContextMenu?: function', // 上下文菜单事件回调函数。
  42. 'onReady?: function' // 组件就绪回调函数。
  43. );
  44. protected function build()
  45. {
  46. global $app;
  47. list($width, $height) = $this->prop(array('width', 'height'));
  48. $dataVarName = "_treemap_$this->gid";
  49. $treemapPath = $app->getWebRoot() . 'js/zui/treemap/index.html?options=' . $dataVarName;
  50. $options = $this->props->pick(array('hotkeyEnable', 'hotkeys', 'lang', 'langs', 'data', 'nodeTeamplate', 'hSpace', 'vSpace', 'canvasPadding', 'removingNodeTip', 'lineCurvature', 'subLineWidth', 'lineColor', 'lineOpacity', 'lineSaturation', 'lineLightness', 'nodeLineWidth', 'showToggleButton', 'readonly', 'minimap', 'toolbar', 'zoom', 'zoomMax', 'zoomMin', 'minimapHeight', 'onNodeClick', 'afterDrawLines', 'afterRender', 'onReady', 'onContextMenu'));
  51. return array
  52. (
  53. h::jsVar("window.$dataVarName", $options),
  54. h::iframe
  55. (
  56. set::className('treemap-iframe'),
  57. set::src($treemapPath),
  58. set::allowfullscreen(true),
  59. set::allowtransparency(true),
  60. set::frameborder('no'),
  61. set::scrolling('auto'),
  62. set::style(array('width' => $width, 'height' => $height)),
  63. set($this->getRestProps())
  64. )
  65. );
  66. }
  67. }