图表js没有显示图表

时间:2016-11-03 17:56:03

标签: javascript jquery charts chart.js

我尝试在我正在处理的项目中仅显示图表js中的示例。不幸的是,我被迫使用Chart Js 1.x. 我试图从https://github.com/chartjs/Chart.js/blob/master/samples/bar/bar.html实现吧示例 这是一个非常简单的例子我猜它但它没有运行:(



<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/1.1.1/Chart.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>

<canvas id="zeitsteuerungChart"></canvas>
&#13;
&#13;
&#13;

var barChartData = {
        labels: ["January", "February", "March", "April", "May", "June", "July"],
        datasets: [{
            label: 'Dataset 1',
            borderWidth: 1,
            data: [
                "1","1","1","1","1","1","1"
            ]
        }, {
            label: 'Dataset 2',
            borderWidth: 1,
            data: [
                "1","1","1","1","1","1","1"
            ]
        }]
    };
    window.onload = function() {
        var ctx = document.getElementById("zeitsteuerungChart").getContext("2d");
        var myBar = new Chart(ctx, {
            type: 'bar',
            data: barChartData
        });
    };

Chart JS操纵

&#13;
&#13;
<canvas id="zeitsteuerungChart"></canvas>
&#13;
&#13;
&#13;

要素

&#13;
&#13;
<canvas id="zeitsteuerungChart" width="300" height="150" style="width: 300px; height: 150px;"></canvas>
&#13;
&#13;
&#13;

但这就是它。没有图表显示。控制台中没有错误。我也尝试使用jQuery来选择

的画布

&#13;
&#13;
var ctx = $("#zeitsteuerungChart").get(0).getContext("2d");
&#13;
&#13;
&#13;

但效果相同!在该项目的其他子页面上,它的工作非常好!

1 个答案:

答案 0 :(得分:1)

您在v1上使用了图表js v2语法。

for v1

In [1]: import matplotlib.pyplot as plt

In [2]: plt.plot(lines_x,lines_y)

您可以查看图表选项(图表js v1)herecomplete options here