Tuesday, July 29, 2014

Re: I don't understand whats wrong with the way im passing django list to json

the values will show how, but i ran into another problem while trying to input the labels, labels need to be strings so I input them as an array such as the following: ["2014-07-28 14:24:11", "2014-07-28 14:24:11"] I saved it as a simple json in django and pass it to the webbrowser and then conver the json to a javascript value and pass that as the labels. Normally labels is ['sdfsdf','sdfsfs'] which is exactly how I pass mine Ive passed with "" and '' it doesn't matter. I'm trying to use the datetimes as the graph labels.

<script src="{% static 'js/chart.js' %}"></script>
var dates = JSON.parse("{{ date_values }}");
var lineChartData = {
labels : [dates],
datasets : [
label: "CPU Usage in MHZ",
fillColor : "rgba(220,220,220,0.2)",
strokeColor : "rgba(220,220,220,1)",
pointColor : "rgba(220,220,220,1)",
pointStrokeColor : "#fff",
pointHighlightFill : "#fff",
pointHighlightStroke : "rgba(220,220,220,1)",
data : {{cpu_values}}


window.onload = function(){
var ctx = document.getElementById("canvas").getContext("2d");
window.myLine = new Chart(ctx).Line(lineChartData, {
responsive: true


You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/cbccdaa1-c1ec-456f-a9a9-5b4f0512a396%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment