+ zin: add echarts wg.
This commit is contained in:
@@ -1253,3 +1253,11 @@ function detailBody()
|
||||
{
|
||||
return createWg('detailBody', func_get_args());
|
||||
}
|
||||
|
||||
/**
|
||||
* ECharts widget.
|
||||
*/
|
||||
function echarts(): \zin\echarts
|
||||
{
|
||||
return createWg('echarts', func_get_args());
|
||||
}
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
namespace zin;
|
||||
|
||||
class echarts extends wg
|
||||
{
|
||||
public function size(string|int $width, string|int $height)
|
||||
{
|
||||
if(is_numeric($width)) $width = "{$width}px";
|
||||
if(is_numeric($height)) $height = "{$height}px";
|
||||
$this->setProp('_size', array($width, $height));
|
||||
}
|
||||
|
||||
protected function build()
|
||||
{
|
||||
return zui::echarts(inherit($this));
|
||||
}
|
||||
}
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user