🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
## 动态数据图 ![](https://img.kancloud.cn/fa/4e/fa4efcf1c9b9ed281e7494da9ee006b5_1114x1008.png) ~~~[api] post:index/t.dynamic <<< success { "succeed": 1 "msg": "提示信息", "data": { "x_set":[ {"type":"category","boundaryGap":true,"data":"下方X轴数组"}, "type":"category","boundaryGap":true,"data":"上方X轴数组" ], "y_set":[ {"type":"vallue","scale"=>true,"boundaryGap":{"0,5","0.5"}},"name":"Y轴说明","max":"左侧Y轴最大值","min":"左侧Y轴最小值"}, {"type":"vallue","scale"=>true,"boundaryGap":{"0,5","0.5"}},"name":"Y轴说明","max":"右侧Y轴最大值","min":"右侧Y轴最小值"} ], data:[{ "name":"数据说明", "type":"图表类型 bar 柱状图 line 折线图", "xAxisIndex":"1绑定到上方X轴", "yAxisIndex":"1绑定到右侧Y轴", "data":"数据数组" }] "title":"图表标题", "subtext":"副标题", "legend_show":"数据说明显示标识", "legend_data":"数据说明数组", "url": "请求地址,若为字符串则为api中的地址,如果为数组则为model中的地址", "second": "动态获取值的间隔时间,毫秒值", "param":"请求间隔时间,毫秒数" "loop": "下一个循环标识(若卡片加载完则不需要填写)", } } <<< error { "succeed": 0, "msg": "提示信息" } ~~~ ~~~ $data = []; //>数据 $second = 3; //>查询间隔秒数 $data['second'] = $second*1000; //>X轴配置数据 $x_set = $obj =[]; for($i=0;$i<$len;$i++){ $obj[] = date('H:i:s',($time-$second*$i)); } sort($obj); $x_set[] = ['type'=>'category','boundaryGap'=>true,'data'=>$obj]; $x_set[] = ['type'=>'category','boundaryGap'=>true,'data'=>$obj]; $data['x_set'] = $x_set; //>Y轴配置数据 $y_set = []; $y_set[] = ['type'=>'value','scale'=>true,'boundaryGap'=>[0.5, 0.5],'name'=>'价格','max'=>30,'min'=>0]; $y_set[] = ['type'=>'value','scale'=>true,'boundaryGap'=>[0.5, 0.5],'name'=>'预购量','max'=>1200,'min'=>0]; $data['y_set'] = $y_set; //数据 $obj = []; $obj[] = ['name'=>'预购队列','type'=>'bar','xAxisIndex'=>1,'yAxisIndex'=>1,'data'=>[230,742,342,612,344,114,623,110,190,230]]; $obj[] = ['name'=>'最新成交价','type'=>'line','data'=>[19,6,24,12,14,11,23,11,19,23]]; $data['data'] = $obj; $data['url'] = 'index/p.dynamic'; $data['param'] = ['P'=>1]; //>标题 $data['title'] = '图表标题'; $data['subtext'] = '副标题'; //>数据说明 $data['legend_show'] = false; //>数据说明是否显示 $data['legend_data'] = ['最新成交价', '预购队列']; //>数据说明 $json['data'] = $data; ~~~