vendredi 6 février 2015

ChartJS Issues / Wordpress


Vote count:

0




So, I've got an issue with ChartJS; I've wanting to add charts to different areas of my site, and I've been able to get it to work with one chart but now I'm trying to add a separate chart (that isn't even on the same page as the first) and it won't load at all. It's the oddest thing.


Here's my script for the charts:



var wins = $("#wins").text();
var losses = $("#losses").text();
var draws = $("#draws").text();
var winsstrike = $("#wins-strike").text();
var winsgrapple = $("#wins-grapple").text();
var winssubmit = $("#wins-submit").text();
var winsother = $("#wins-other").text();

var recorddata = [{
value: 1*wins,
color: "#eb3f3d",
label: "Wins"
}, {
value: 1*losses,
color: "#ec582a",
label: "Losses"
}, {
value: 1*draws,
color: "#f8a430",
label: "Draws"
}

]

var recordoptions = {
animation: true,
segmentShowStroke : true,
segmentStrokeColor : "#191919",
percentageInnerCutout : 70

};

var winsdata = [{
value: 1*winsstrike,
color: "#eb3f3d",
label: "Strike"
}, {
value: 1*winsgrapple,
color: "#E82521",
label: "Grappling"
}, {
value: 1*winssubmit,
color: "#CB1815",
label: "Submission"
}, {
value: 1*winsother,
color: "#A61411",
label: "Other"
}

]

var winsoptions = {
animation: true,
segmentShowStroke : true,
segmentStrokeColor : "#191919",
percentageInnerCutout : 90
};

var c = $('#recordChart');
var ct = c.get(0).getContext('2d');
var ctx = document.getElementById("recordChart").getContext("2d");
myNewChart = new Chart(ct).Doughnut(recorddata, recordoptions);

var c1 = $('#winsbyChart');
var ct1 = c1.get(0).getContext('2d');
var ctx1 = document.getElementById("winsbyChart").getContext("2d");
myNewChart1 = new Chart(ct1).Doughnut(winsdata, winsoptions);


I have no clue why they won't work; the first chart, posting the #recordChart works flawlessly, but the second doesn't. I know the code is fine because I built a fiddle for it. I just can't figure out why the hell it won't work on the second chart (#winsbyChart).


Is there a conflict between the charts I'm not seeing? This is just so frustrating. Any help would be appreicated. Thanks.



asked 21 secs ago







ChartJS Issues / Wordpress

Aucun commentaire:

Enregistrer un commentaire