我有一个从SharePoint列表创建的图表,它可以在Chrome中运行但在IE 11中不起作用。当我在IE 11中进行调试时,我收到错误SCRIPT438: Object doesn't support property or method 'values'
。我是JavaScript的新手。
任何人都可以告诉我可能是什么修复或我缺少什么
我正在使用chart.js和ajax。
<script type="text/javascript" src="/sites/carm/Shared%20Documents/Chart.min.js"></script>
<script type="text/javascript" src="/sites/carm/Shared%20Documents/jquery-1.12.4.min.js"></script>
<script type="text/javascript">
$.ajax({
url: "/sites/carm/_api/web/lists/getbytitle('ATO%20Conditions')/items?$select=ID,Title,m4gs&$top=5000",
type: "GET",
headers: {
"accept": "application/json;odata=verbose",
},
success: function(data) {
if (data.d.results.length > 0) {
var inactiveSet = {};
var activeSet = {};
var otherSet = {};
var totalActive = 0;
var totalInActive = 0;
var totalOther = 0;
var initZero = 0;
$.each(data.d.results, function(index, item) {
if (item.m4gs === "Completed") {
totalInActive++
if (item.Title in inactiveSet) {
inactiveSet[item.Title]++;
} else {
inactiveSet[item.Title] = 1;
activeSet[item.Title] = initZero;
otherSet[item.Title] = initZero;
}
} else if (item.m4gs === "Active") {
totalActive++
if (item.Title in activeSet) {
activeSet[item.Title]++;
} else {
inactiveSet[item.Title] = initZero;
activeSet[item.Title] = 1;
otherSet[item.Title] = initZero;
}
} else {
totalOther++
if (item.Title in otherSet) {
otherSet[item.Title]++;
} else {
inactiveSet[item.Title] = initZero;
activeSet[item.Title] = initZero;
otherSet[item.Title] = 1;
}
}
});
}
var inactiveOrdered = {};
var activeOrdered = {};
var otherOrdered = {};
Object.keys(activeSet).sort().forEach(function(key) {
activeOrdered[key] = activeSet[key];
});
Object.keys(inactiveSet).sort().forEach(function(key) {
inactiveOrdered[key] = inactiveSet[key];
});
Object.keys(otherSet).sort().forEach(function(key) {
otherOrdered[key] = otherSet[key];
});
var ctx = document.getElementById("myChart").getContext("2d");
var data = {
labels: Object.keys(activeOrdered),
datasets: [{
label: "Active",
fillColor: "steelblue",
data: Object.values(activeOrdered)
},
{
label: "Completed",
fillColor: "orange",
data: Object.values(inactiveOrdered)
}
]
};
....
</script>
错误来自以
开头的行...
var data = {
labels: Object.keys(activeOrdered),
...
答案 0 :(得分:4)
发生错误是因为Internet Explorer中不支持 Object.values()
。
请参阅Object.values()
了解data: Object.keys(activeOrdered).map(function(key) {return activeOrdered[key];})
这是一种解决方法,您可以改为使用......
data: Object.keys(inactiveOrdered).map(function(key) {return inactiveOrdered[key];})
和......
import argparse
parser = argparse.ArgumentParser(description='Intro', add_help=False)
parser.add_argument('--help', action='help', help='My Help')
parser.add_argument('--master', default='abc', help='yadayada ydad', metavar='')
parser.add_argument('--slave', help='yadayada ydad', metavar='')
args = parser.parse_args()
arg_dict = vars(args)
print(arg_dict)