社区所有版块导航
Python
python开源   Django   Python   DjangoApp   pycharm  
DATA
docker   Elasticsearch  
aigc
aigc   chatgpt  
WEB开发
linux   MongoDB   Redis   DATABASE   NGINX   其他Web框架   web工具   zookeeper   tornado   NoSql   Bootstrap   js   peewee   Git   bottle   IE   MQ   Jquery  
机器学习
机器学习算法  
Python88.com
反馈   公告   社区推广  
产品
短视频  
印度
印度  
Py学习  »  问与答

django 使用Chart.js

MrCRR • 10 年前 • 2870 次点击  
<script>  
    var barChartData = {  
        labels : {{ listone }},           #listone 是我从views传过来的一个列表,而且我验证了,它是有值得
        datasets : [ {  
            fillColor : "rgba(220,220,220,0.5)",  
            strokeColor : "rgba(220,220,220,1)",  
            data : [ 65, 59, 90, 81, 56, 55, 40 ]  
        }, {  
            fillColor : "rgba(151,187,205,0.5)",  
            strokeColor : "rgba(151,187,205,1)",  
            data : [ 28, 48, 40, 19, 96, 27, 100 ]  
        } ]  
    };

    var ctx = document.getElementById("bar").getContext("2d");  
    var myNewChart = new Chart(ctx).Bar(barChartData);  
    //new Chart(document.getElementById("bar").getContext("2d")).Bar(barChartData);  
</script>

想用动态数据生成图表,但用以上代码画不出图(我把{{listone}}改成静态的[“1”,“2”]这样就可以生成),何解?

Python社区是高质量的Python/Django开发社区
本文地址:http://www.python88.com/topic/1107
 
2870 次点击