使用PHP / MySQL

时间:2017-02-16 14:12:35

标签: javascript php mysql chart.js

我在项目中使用charts.js(http://www.chartjs.org/

我想显示一个图表,显示过去12个月中每个月的下载次数。

您可以在我的数据库中查看日期时间,我该怎么做?

这是我的js

<!----- CHARTS / DOWNLOADS ----->
<script>
var ctx = document.getElementById("downloads");
var myChart = new Chart(ctx, {
    type: 'line',
    data: {
        labels: ["", "", "", "", "", "", "", "", "", "", "", ""],
        datasets: [{
            label: '# of Downloads',
            data: [12, 23, 45, 65, 67, 87, 123, 342, 123, 342, 256, 467],
            backgroundColor: [
                'rgba(246, 10, 36, 1)'
            ],
            borderColor: [
                'rgba(246, 10, 36, 0.2)'
            ],
            borderWidth: 1
        }]
    },
    options: {
        scales: {
            yAxes: [{
                ticks: {
                    beginAtZero:true
                }
            }]
        }
    }
});
</script>

这是我的数据库

2	YE1lHiWApOYN	twitter	NULL	NULL	2017-02-10 13:30:13	3	2904395385	NULL
3	YE1lHiWApOYN	twitter	NULL	World Trade Forums	2017-02-10 13:31:06	3	2904395385	NULL
4	YE1lHiWApOYN	twitter	NULL	World Trade Forums	2017-02-10 13:36:23	3	2904395385	NULL
5	YE1lHiWApOYN	twitter	NULL	World Trade Forums	2017-02-10 13:59:58	3	2904395385	NULL
6	YE1lHiWApOYN	twitter	NULL	World Trade Forums	2017-02-10 14:04:02	3	2904395385	NULL
7	YE1lHiWApOYN	twitter	NULL	World Trade Forums	2017-02-10 14:05:31	3	2904395385	NULL
8	YE1lHiWApOYN	twitter	NULL	World Trade Forums	2017-02-10 14:48:35	3	2904395385	NULL
9	YE1lHiWApOYN	twitter	NULL	World Trade Forums	2017-02-10 14:50:43	3	2904395385	NULL
10	YE1lHiWApOYN	twitter	NULL	World Trade Forums	2017-02-10 14:51:55	3	2904395385	NULL
11	YE1lHiWApOYN	twitter	NULL	World Trade Forums	2017-02-10 14:53:33	3	2904395385	NULL
12	YE1lHiWApOYN	twitter	NULL	World Trade Forums	2017-02-10 14:55:20	3	2904395385	NULL
13	YE1lHiWApOYN	twitter	NULL	World Trade Forums	2017-02-10 15:08:08	3	2904395385	NULL
14	YE1lHiWApOYN	twitter	NULL	World Trade Forums	2017-02-10 15:12:28	3	2904395385	NULL
15	YE1lHiWApOYN	twitter	NULL	World Trade Forums	2017-02-10 15:14:43	3	2904395385	NULL
16	YE1lHiWApOYN	twitter	NULL	Brad Fletcher	2017-02-10 15:16:02	3	378143228	NULL
17	Sdm4HhcSIDhC	twitter	NULL	Brad Fletcher	2017-02-10 16:40:48	5	378143228	NULL
18	YE1lHiWApOYN	twitter	NULL	Deep House	2017-02-10 18:48:44	3	2886815776	NULL
19	YE1lHiWApOYN	twitter	NULL	Deep House	2017-02-10 18:50:32	3	2886815776	NULL
20	YE1lHiWApOYN	twitter	NULL	Deep House	2017-02-10 19:14:56	3	2886815776	NULL
21	YE1lHiWApOYN	twitter	NULL	World Trade Forums	2017-02-10 19:27:19	3	2904395385	85.255.235.6
22	sJ8UcXChXOXh	twitter	NULL	World Trade Forums	2017-02-10 19:53:44	3	2904395385	85.255.235.6
23	sJ8UcXChXOXh	twitter	NULL	Deep House	2017-02-10 20:11:00	3	2886815776	85.255.235.6
24	sJ8UcXChXOXh	twitter	NULL	World Trade Forums	2017-02-10 20:38:13	3	2904395385	85.255.235.6

0 个答案:

没有答案