v1.php 848 B

12345678910111213141516171819202122232425
  1. <?php
  2. namespace zin;
  3. class graph extends wg
  4. {
  5. /**
  6. * @var mixed[]
  7. */
  8. protected static $defineProps = array(
  9. 'type?: string', // 'TreeGraph' or 'Graph', default is 'TreeGraph'
  10. 'responsive?: bool=false',
  11. 'width?: number|string="100%"',
  12. 'height?: number|string="500"',
  13. 'graphID?: number=0',
  14. );
  15. protected function build()
  16. {
  17. list($type, $width, $height, $responsive, $graphID) = $this->prop(array('type', 'width', 'height', 'responsive', 'graphID'));
  18. if(empty($graphID)) $graphID = uniqid();
  19. return zui::graph(set::_id('zin_graph_' . $graphID), set::type($type), set::responsive($responsive), set::_style(array('width' => is_int($width) ? "{$width}px" : $width, 'height' => is_int($height) ? "{$height}px" : $height)), set($this->getRestProps()));
  20. }
  21. }