2025-06-27 10:04:22 +08:00

270 lines
7.3 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/// <reference path="C:\Users\Administrator\Desktop\WEI.UIPro\WEI.UIPro20160726\WEI.UIPro\WEI.UIPro\WEI.UIPro\Scripts/linq.js" />
//柱状图
app.controller('barhtmlCtrl', ['$scope', 'myFactory','$timeout', function ($scope, myFactory,$timeout) {
$scope.DT = [];
var MyFilter = "采样区县";
myFactory.getselect({$select : MyFilter }, function (data) {
//alert(angular.toJson(data));
var aaa= Enumerable.From(data.value).Distinct('$.采样区县').ToArray();
angular.forEach(aaa, function (data) {
$scope.DT.push(data.采样区县);
})
// MyData($scope.DT);
//$scope.legend = ["区县抽检数据表"];
//$scope.item = ['美国上市第一个月报表', '美国上市第二个月报表', '美国上市第三个月报表', '美国上市第四个月报表', '美国上市第五个月报表', '美国上市第六个月报表']; //y轴展示数据
//$scope.data = [
// [1, 10, 20, 30, 40, 50]
//];
})
function MyData(name) {
$scope.legend = ["区县抽检数据表"];
$scope.item = $scope.DT //Y轴展示数据
alert($scope.item);
$scope.data = [
[1, 10, 20, 30, 40, 50]
];
}
$scope.legend = ["区县抽检数据表"];
$scope.item = ['闸北区', '静安区', '虹口区', '普陀区', '宝山', '美国上市第六个月报表']; //y轴展示数据
$scope.data = [
[1, 10, 20, 30, 40, 50]
];
}])
app.directive('barwy', function () {
return {
scope: {
id: "@",
legend: "=",
item: "=",
data: "=",
newfunc: '&'
},
restrict: 'E', // E = Element, A = Attribute, C = Class, M = Comment
template: '<div style="height:400px"></div>',
replace: true,
controller: function ($scope) {
//var dT = $scope.newfunc();
var option = {
tooltip: {
show: true,
trigger: "axis"
},
legend: { data: $scope.legend },
xAxis: [{
type: 'value'
}],
yAxis: [{
type: 'category',
data: $scope.item
}],
series: function () {
var serie = [];
for (var i = 0; i < $scope.legend.length; i++) {
var item = {
name: $scope.legend[i],
type: 'bar',
data: $scope.data[i]
};
serie.push(item);
}
return serie;
}()
}
$scope.option = option;
},
link: function ($scope, iElm, iAttrs, controller) {
//// 基于准备好的dom初始化echarts图表
var myChart = echarts.init(document.getElementById($scope.id), 'macarons');
//// 为echarts对象加载数据
myChart.setOption($scope.option);
$scope.$watch('',
function () {
//// 基于准备好的dom初始化echarts图表
var myChart = echarts.init(document.getElementById($scope.id), 'macarons');
//// 为echarts对象加载数据
myChart.setOption($scope.option);
}
);
}
};
});
//食品,项目,解决方法,评判标准,计量标准,
//=============================================================================================================================
app.controller('EcharesCtrl', ['$scope', 'myFactory', function ($scope, myFactory) {
$scope.legend = ['张三', '李四', '王五', '刘麻子', '真美丽'];
$scope.item = ['周一', '周二', '周三', '周四', '周五', '周六', '周日'];
$scope.data = [
{
name: '邮件营销',
type: 'line',
stack: '总量',
areaStyle: { normal: {} },
data: [120, 132, 101, 134, 90, 230, 210]
},
{
name: '联盟广告',
type: 'line',
stack: '总量',
areaStyle: { normal: {} },
data: [220, 182, 191, 234, 290, 330, 310]
},
{
name: '视频广告',
type: 'line',
stack: '总量',
areaStyle: { normal: {} },
data: [150, 232, 201, 154, 190, 330, 410]
},
{
name: '直接访问',
type: 'line',
stack: '总量',
areaStyle: { normal: {} },
data: [320, 332, 301, 334, 390, 330, 320]
},
{
name: '搜索引擎',
type: 'line',
stack: '总量',
label: {
normal: {
show: true,
position: 'top'
}
},
areaStyle: { normal: {} },
data: [820, 932, 901, 934, 1290, 1330, 1320]
}
];
}])
app.directive('linewy', function () {
return {
scope: {
id: "@",
legend: "=",
item: "=",
data: "="
},
restrict: 'E', // E = Element, A = Attribute, C = Class, M = Comment
template: '<div style="height:400px"></div>',
replace: true,
link: function ($scope, iElm, iAttrs, controller) {
var option = {
title: {
text: '堆叠区域图'
},
tooltip: {
trigger: 'axis'
},
legend: {
data: $scope.legend
},
toolbox: {
feature: {
saveAsImage: {}
}
},
grid: {
left: '3%',
right: '4%',
bottom: '3%',
containLabel: true
},
xAxis: [
{
type: 'category',
boundaryGap: false,
data: $scope.item
}
],
yAxis: [
{
type: 'value'
}
],
series: function () {
var serie = [];
for (var i = 0; i < $scope.legend.length; i++) {
var item = {
name: $scope.legend[i],
type: 'line',
areaStyle: { normal: {} },
data: $scope.data[i].data
};
//alert(JSON.stringify( item));
serie.push(item);
}
return serie;
}()
};
// 基于准备好的dom初始化echarts图表
var myChart = echarts.init(document.getElementById($scope.id), 'macarons');
// 为echarts对象加载数据
myChart.setOption(option);
}
};
});