diff --git a/lib/zin/func.php b/lib/zin/func.php index c971f6e2d5..26f2b40f87 100644 --- a/lib/zin/func.php +++ b/lib/zin/func.php @@ -1253,3 +1253,11 @@ function detailBody() { return createWg('detailBody', func_get_args()); } + +/** + * ECharts widget. + */ +function echarts(): \zin\echarts +{ + return createWg('echarts', func_get_args()); +} diff --git a/lib/zin/wg/echarts/v1.php b/lib/zin/wg/echarts/v1.php new file mode 100644 index 0000000000..17b5f15e03 --- /dev/null +++ b/lib/zin/wg/echarts/v1.php @@ -0,0 +1,18 @@ +setProp('_size', array($width, $height)); + } + + protected function build() + { + return zui::echarts(inherit($this)); + } +} diff --git a/lib/zin/zui/zui.class.php b/lib/zin/zui/zui.class.php index 7290e41104..e2283c8a4a 100644 --- a/lib/zin/zui/zui.class.php +++ b/lib/zin/zui/zui.class.php @@ -19,11 +19,18 @@ require_once __DIR__ . DS . 'toggle.class.php'; class zui extends wg { - static $defineProps = '_name:string, _to?:string, _tag:string="div", _toProps?: array'; + protected static $defineProps = array( + '_name:string', + '_to?:string', + '_tag:string="div"', + '_toProps?: array', + '_size?: array' + ); protected function build() { - list($name, $target, $tagName, $targetProps) = $this->prop(array('_name', '_to', '_tag', '_toProps')); + list($name, $target, $tagName, $targetProps, $size) = $this->prop(array('_name', '_to', '_tag', '_toProps', '_size')); + list($width, $height) = $size; $selector = empty($target) ? "[data-zin-id='$this->gid']" : $target; $options = $this->props->skip(array_keys(static::getDefinedProps())); return array @@ -32,7 +39,9 @@ class zui extends wg ( $tagName, set($targetProps), - set('data-zin-id', $this->gid) + set('data-zin-id', $this->gid), + setStyle('width', $width), + setStyle('height', $height), ) : null, $this->children(), h::jsCall('~zui.create', $name, $selector, $options)