I have a graph i created from a SharePoint list and it works in Chrome but does not work in IE 11. When i went to debug in IE 11 and I get the error SCRIPT438: Object doesn't support property or method 'values'
. I am fairly new to JavaScript.
Can anybody tell me what may be a fix or what I am missing
I am using chart.js and 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>
The error is coming from the line starting with
...
var data = {
labels: Object.keys(activeOrdered),
...
The error is occurring because, Object.values()
is not supported in Internet Explorer.
see browser compatibility for Object.values()
Here is a workaround, that you could use instead ...
data: Object.keys(activeOrdered).map(function(key) {return activeOrdered[key];})
and ...
data: Object.keys(inactiveOrdered).map(function(key) {return inactiveOrdered[key];})
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With