Commit e01360ba authored by Matthias Zimny's avatar Matthias Zimny

update chart package to version 2.3.0

parent 699012b2
......@@ -52,6 +52,5 @@ aslagle:reactive-table
patrickml:braintree
email
percolate:synced-cron
chart:chart
jshint
browser-policy
......@@ -33,7 +33,6 @@ caching-compiler@1.0.6
caching-html-compiler@1.0.6
callback-hook@1.0.9
cfs:http-methods@0.0.32
chart:chart@1.0.1-beta.4
check@1.2.3
coffeescript@1.1.4
ddp@1.2.5
......
import {Learned} from "./learned.js";
export function Graph(user_id, card_id) {
var query = {};
if (user_id !== undefined) {
query.user_id = user_id;
}
if (card_id !== undefined) {
query.cardset_id = card_id;
}
query.box = 1;
var box1 = Learned.find(query).count();
query.box = 2;
var box2 = Learned.find(query).count();
query.box = 3;
var box3 = Learned.find(query).count();
query.box = 4;
var box4 = Learned.find(query).count();
query.box = 5;
var box5 = Learned.find(query).count();
query.box = 6;
var box6 = Learned.find(query).count();
var userData = [Number(box1), Number(box2), Number(box3), Number(box4), Number(box5), Number(box6)];
return {
labels: [TAPi18n.__('subject1'), TAPi18n.__('subject2'), TAPi18n.__('subject3'), TAPi18n.__('subject4'), TAPi18n.__('subject5'), TAPi18n.__('subject6')],
datasets: [{
fillColor: "rgba(242,169,0,0.5)",
strokeColor: "rgba(74,92,102,0.2)",
pointColor: "rgba(220,220,220,1)",
pointStrokeColor: "#fff",
data: userData
}]
};
}
......@@ -5,6 +5,9 @@ import {Template} from "meteor/templating";
import {Session} from "meteor/session";
import {Cardsets} from "../../../api/cardsets.js";
import {Graph} from "../../../api/graph.js";
import {Charts} from "chart.js";
import {Learned} from "../../../api/learned.js";
import "./admin_users.html";
import "./admin_user.js";
......@@ -21,24 +24,57 @@ Meteor.subscribe('learned', function () {
*/
export function drawGraph() {
var query = {};
if (undefined !== undefined) {
query.user_id = Meteor.userId();
}
if (undefined !== undefined) {
query.cardset_id = undefined;
}
query.box = 1;
var box1 = Learned.find(query).count();
query.box = 2;
var box2 = Learned.find(query).count();
query.box = 3;
var box3 = Learned.find(query).count();
query.box = 4;
var box4 = Learned.find(query).count();
query.box = 5;
var box5 = Learned.find(query).count();
query.box = 6;
var box6 = Learned.find(query).count();
var userData = [Number(box1), Number(box2), Number(box3), Number(box4), Number(box5), Number(box6)];
if (Session.get('data_loaded')) {
var canvas = document.getElementById("adminChart");
var ctx = document.getElementById("adminChart").getContext("2d");
new Chart(ctx).Bar(Graph(undefined, undefined),
{
responsive: true,
options: {
scales: {
yAxes: [{
stacked: true
}]
var adminChart = new Chart(ctx, {
type: 'bar',
data: {
labels: [TAPi18n.__('subject1'), TAPi18n.__('subject2'), TAPi18n.__('subject3'), TAPi18n.__('subject4'), TAPi18n.__('subject5'), TAPi18n.__('subject6')],
datasets: [
{
backgroundColor: "rgba(242,169,0,0.5)",
borderColor: "rgba(74,92,102,0.2)",
borderWidth: 1,
data: userData,
label: 'Anzahl Karten'
}
}
});
canvas.style.width = '100%';
canvas.style.height = '100%';
canvas.width = canvas.offsetWidth;
canvas.height = canvas.offsetHeight;
]
},
options: {
responsive: true,
legend: {
display: false
},
scales: {
yAxes: [{
ticks: {
stepSize: 1
}
}]
}
}
});
}
}
......
......@@ -213,7 +213,7 @@
<div id="container" style="min-width: 100%;
max-width: 100%; min-height: 100%; max-height: 100%; margin: 0 auto">
<h3 class="panel-title">{{_ "admin.learnedCardsets"}}</h3>
<canvas id="boxChart" width="800" height="470"></canvas>
<canvas id="boxChart" width="800" height="470" style="margin-top: 10px"></canvas>
</div>
</div>
</template>
......
......@@ -23,9 +23,57 @@ Meteor.subscribe('learned', function () {
});
function drawGraph() {
var query = {};
if (Meteor.userId() !== undefined) {
query.user_id = Meteor.userId();
}
if (Router.current().params._id !== undefined) {
query.cardset_id = Router.current().params._id;
}
query.box = 1;
var box1 = Learned.find(query).count();
query.box = 2;
var box2 = Learned.find(query).count();
query.box = 3;
var box3 = Learned.find(query).count();
query.box = 4;
var box4 = Learned.find(query).count();
query.box = 5;
var box5 = Learned.find(query).count();
query.box = 6;
var box6 = Learned.find(query).count();
var userData = [Number(box1), Number(box2), Number(box3), Number(box4), Number(box5), Number(box6)];
if (Session.get('data_loaded')) {
var ctx = document.getElementById("boxChart").getContext("2d");
new Chart(ctx).Bar(Graph(Meteor.userId(), Router.current().params._id), {responsive: true});
var boxChart = new Chart(ctx, {
type: 'bar',
data: {
labels: [TAPi18n.__('subject1'), TAPi18n.__('subject2'), TAPi18n.__('subject3'), TAPi18n.__('subject4'), TAPi18n.__('subject5'), TAPi18n.__('subject6')],
datasets: [
{
backgroundColor: "rgba(242,169,0,0.5)",
borderColor: "rgba(74,92,102,0.2)",
borderWidth: 1,
data: userData,
label: 'Anzahl Karten'
}
]
},
options: {
responsive: true,
legend: {
display: false
},
scales: {
yAxes: [{
ticks: {
stepSize: 1
}
}]
}
}
});
}
}
......
......@@ -30,16 +30,60 @@ Meteor.subscribe('learned', function () {
});
export function drawGraph() {
var query = {};
if (Meteor.userId() !== undefined) {
query.user_id = Meteor.userId();
}
if (undefined !== undefined) {
query.cardset_id = undefined;
}
query.box = 1;
var box1 = Learned.find(query).count();
query.box = 2;
var box2 = Learned.find(query).count();
query.box = 3;
var box3 = Learned.find(query).count();
query.box = 4;
var box4 = Learned.find(query).count();
query.box = 5;
var box5 = Learned.find(query).count();
query.box = 6;
var box6 = Learned.find(query).count();
var userData = [Number(box1), Number(box2), Number(box3), Number(box4), Number(box5), Number(box6)];
if (Session.get('data_loaded')) {
var ctx = document.getElementById("profileChart").getContext("2d");
new Chart(ctx).Bar(Graph(Meteor.userId(), undefined),
{
responsive: true
});
var profileChart = new Chart(ctx, {
type: 'bar',
data: {
labels: [TAPi18n.__('subject1'), TAPi18n.__('subject2'), TAPi18n.__('subject3'), TAPi18n.__('subject4'), TAPi18n.__('subject5'), TAPi18n.__('subject6')],
datasets: [
{
backgroundColor: "rgba(242,169,0,0.5)",
borderColor: "rgba(74,92,102,0.2)",
borderWidth: 1,
data: userData,
label: 'Anzahl Karten'
}
]
},
options: {
responsive: true,
legend: {
display: false
},
scales: {
yAxes: [{
ticks: {
stepSize: 1
}
}]
}
}
});
}
}
function getLvl() {
var user = Meteor.users.findOne(Router.current().params._id);
if (user === undefined) {
......
......@@ -5,20 +5,20 @@
"start": "meteor run"
},
"dependencies": {
"chart.js": "^2.3.0",
"meteor-node-stubs": "~0.2.0",
"react": "^15.0.2"
},
"version": "1.0.0",
"main": "index.js",
"devDependencies": {},
"author": "",
"license": "ISC",
"description": "",
"devDependencies": {
"gulp": "^3.9.1",
"gulp-jscs": "^3.0.2",
"gulp-jshint": "^2.0.0",
"gulp-watch": "^4.3.5",
"jshint-stylish": "^2.1.0"
}
},
"author": "",
"license": "ISC",
"description": ""
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment