layui.define(function(exports){
var admin = layui.admin;
//区块轮播切换
layui.use(['admin', 'carousel'], function(){
var $ = layui.$
,admin = layui.admin
,carousel = layui.carousel
,element = layui.element
,device = layui.device();
//轮播切换,这一段必须要,不然echarts无法完成渲染
$('.layadmin-carousel').each(function(){
var othis = $(this);
carousel.render({
elem: this
,width: '100%'
,arrow: 'none'
,interval: othis.data('interval')
,autoplay: othis.data('autoplay') === true
,trigger: (device.ios || device.android) ? 'click' : 'hover'
,anim: othis.data('anim')
});
});
element.render('progress');
});
//访问量
layui.use(['carousel', 'echarts'], function(){
var $ = layui.$
,carousel = layui.carousel
,echarts = layui.echarts;
var echartsApp = [], options = [
{
tooltip : {
trigger: 'axis'
},
calculable : true,
legend: {
data:['访问量','下载量','平均访问量']
},
xAxis : [
{
type : 'category',
data : ['1月','2月','3月','4月','5月','6月','7月','8月','9月','10月','11月','12月']
}
],
yAxis : [
{
type : 'value',
name : '访问量',
axisLabel : {
formatter: '{value} 万'
}
},
{
type : 'value',
name : '下载量',
axisLabel : {
formatter: '{value} 万'
}
}
],
series : [
{
name:'访问量',
type:'line',
data:[900, 850, 950, 1000, 1100, 1050, 1000, 1150, 1250, 1370, 1250, 1100]
},
{
name:'下载量',
type:'line',
yAxisIndex: 1,
data:[850, 850, 800, 950, 1000, 950, 950, 1150, 1100, 1240, 1000, 950]
},
{
name:'平均访问量',
type:'line',
data:[870, 850, 850, 950, 1050, 1000, 980, 1150, 1000, 1300, 1150, 1000]
}
]
}
]
,elemDataView = $('#LAY-index-pagetwo').children('div')
,renderDataView = function(index){
echartsApp[index] = echarts.init(elemDataView[index], layui.echartsTheme);
echartsApp[index].setOption(options[index]);
window.onresize = echartsApp[index].resize;
};
//没找到DOM,终止执行
if(!elemDataView[0]) return;
//请求服务端获取到数据后渲染图表
//admin.req({
// url: layui.setter.url + '/url'
//, type: 'post'
// , data: PARAM_DATE
//, done: function (res) { //这里要说明一下:done 是只有 response 的 code 正常才会执行。而 succese 则是只要 http 为 200 就会执行
//$.each(getRecentDay(-7,res.data), function(index, tmp) {
//categories.push(tmp.reg_date);
// data.push(tmp.reg_num);
//});
renderDataView(0);
//}
//});
});
exports('test', {})
});
引用图表插件:
<div class="layui-carousel layadmin-carousel layadmin-dataview" data-anim="fade" lay-filter="LAY-index-pagetwo">
<div carousel-item id="LAY-index-pagetwo">
<div><i class="layui-icon layui-icon-loading1 layadmin-loading"></i></div>
</div>
</div>
<script>
layui.config({
base: '/frame/layuiadmin/' //静态资源所在路径
}).extend({
index: 'lib/index' //主入口模块
}).use(['index', 'test']);
</script>
网友评论