我使用 angularjs、php 和 mysql 创建了一个应用程序。我设置了一个 RESTful API,它将 mysql 数据导出到 json。我想知道如何使用下面的 JSON 数据在浮点折线图上单独绘制“Copra_Mc”数据。
[
{
"productionhourlyNumber": "94",
"Copra_Mc": "5.88741898",
"Copra_Oil": "0.64851388"
},
{
"productionhourlyNumber": "93",
"Copra_Mc": "6.88741898",
"Copra_Oil": ""
},
{
"productionhourlyNumber": "92",
"Copra_Mc": "5.89998",
"Copra_Oil": ""
}
]
HTML
<div class="tile-body" ng-controller="LineChartCtrl">
<flot dataset="dataset" options="options" height="250px"></flot>
</div>
JS
我在 Controller 中设置了虚拟 json,我想使用 $http 而不是虚拟数据从上面的 json 中获取数据
.controller('LineChartCtrl', function ($scope) {
$scope.dataset = [{
data: [[1,20.3],[2,5.9],[3,7.2],[4,8],[5,7],[6,6.5],[7,6.2],[8,6.7],[9,7.2],[10,7],[11,6.8],[12,7]],
label: 'Copra_Mc',
points: {
show: true,
radius: 6
}
}, {
data: [[1,6.6],[2,7.4],[3,8.6],[4,9.4],[5,8.3],[6,7.9],[7,7.2],[8,7.7],[9,8.9],[10,8.4],[11,8],[12,8.3]],
label: 'OEE',
points: {
show: true,
radius: 6
}
}, {
data: [[1,9.6],[2,7.4],[3,8.6],[4,13.4],[5,8.3],[6,7.9],[7,14.2],[8,7.7],[9,8.9],[10,8.4],[11,8],[12,8.3]],
label: 'OVE',
points: {
show: true,
radius: 6
}
}];
}
};
})
图表如下所示
最佳答案
您需要使用流程图指令来通过$http使用json
在此处下载 angularjs 中的流程图指令
https://www.npmjs.com/package/angular-flot
https://github.com/ErikAugust/angularjs-flot-chart-directive
并使用与此类似的
http://www.codeandyou.com/2015/02/injecting-service-to-directives-in.html
关于php - 使用 angularjs 和 json 使用 $http 在浮点图上绘制数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29062455/