ITM13 TermStatistics Demo

by rwachtler

HTML

<script src="http://www.chartjs.org/assets/Chart.js"></script>
<h1>Wörter und Anzahl für 21.11.2015</h1>
<canvas id="myChart" width="400" height="400"></canvas>

JavaScript

var loaded = [{
    "id": 1084,
        "amount": 84,
        "logDate": "16.11.2015",
        "website": {
        "id": 1,
            "active": 1,
            "description": "blabla",
            "domain": "http://pswengi.bamb.at"
    },
        "word": {
        "text": "bee",
            "active": 1
    }
}, {
    "id": 1603,
        "amount": 80,
        "logDate": "16.11.2015",
        "website": {
        "id": 1,
            "active": 1,
            "description": "blabla",
            "domain": "http://pswengi.bamb.at"
    },
        "word": {
        "text": "in",
            "active": 1
    }
}, {
    "id": 1392,
        "amount": 78,
        "logDate": "16.11.2015",
        "website": {
        "id": 1,
            "active": 1,
            "description": "blabla",
            "domain": "http://pswengi.bamb.at"
    },
        "word": {
        "text": "do",
            "active": 1
    }
}, {
    "id": 1830,
        "amount": 71,
        "logDate": "16.11.2015",
        "website": {
        "id": 1,
            "active": 1,
            "description": "blabla",
            "domain": "http://pswengi.bamb.at"
    },
        "word": {
        "text": "die",
            "active": 1
    }
}, {
    "id": 527,
        "amount": 68,
        "logDate": "16.11.2015",
        "website": {
        "id": 1,
            "active": 1,
            "description": "blabla",
            "domain": "http://pswengi.bamb.at"
    },
        "word": {
        "text": "sed",
            "active": 1
    }
}];
var labels = [];
var amount = [];
$(loaded).each(function (index) {
    console.log(loaded[index]);
    labels.push(loaded[index].word.text);
    amount.push(loaded[index].amount);
});
var data = {
    labels: labels,
    datasets: [{
        label: "",
        fillColor: "rgba(220,220,220,0.2)",
        strokeColor: "rgba(220,220,220,1)",
        pointColor: "rgba(220,220,220,1)",
        pointStrokeColor: "#fff",
        pointHighlightFill: "#fff",
       ...