Skip to content

Commit

Permalink
time series x axis formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
sylvr3 committed Oct 26, 2015
2 parents 3300f62 + 05b6155 commit 07bdf0a
Show file tree
Hide file tree
Showing 5 changed files with 77 additions and 149 deletions.
16 changes: 0 additions & 16 deletions model/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ const addTrialModel = require('./trial');
const addPatientModel = require('./patient');
const addSurveyTemplateModel = require('./survey-template');
const addSurveyInstanceModel = require('./survey-instance');
const addScheduleTemplateModel = require('./schedule-template');
const addScheduleInstanceModel = require('./schedule-instance');
const addQuestionTemplateModel = require('./question-template');
const addQuestionInstanceModel = require('./question-instance');
const addQuestionOptionModel = require('./question-option');
Expand All @@ -21,7 +19,6 @@ const addQuestionOptionModel = require('./question-option');
const addJoinTrialsAndSurveys = require('./join-trials-and-surveys');
const addJoinSurveysAndQuestions = require('./join-surveys-and-questions');
const addJoinQuestionsAndOptions = require('./join-questions-and-options');
const addJoinPatientsSurveysAndSchedules = require('./join-patients-surveys-and-schedules');

/**
* a DatabaseConfiguration is a collection of the settings needed to connect to the database.
Expand Down Expand Up @@ -59,8 +56,6 @@ module.exports.setup = function (configuration) {
addPatientModel(sequelize);
addSurveyTemplateModel(sequelize);
addSurveyInstanceModel(sequelize);
addScheduleTemplateModel(sequelize);
addScheduleInstanceModel(sequelize);
addQuestionTemplateModel(sequelize);
addQuestionInstanceModel(sequelize);
addQuestionOptionModel(sequelize);
Expand All @@ -69,15 +64,12 @@ module.exports.setup = function (configuration) {
addJoinTrialsAndSurveys(sequelize);
addJoinSurveysAndQuestions(sequelize);
addJoinQuestionsAndOptions(sequelize);
addJoinPatientsSurveysAndSchedules(sequelize);

// Get the newly created ORM wrappers
const patient = sequelize.model('patient');
const questionInstance = sequelize.model('question_instance');
const questionOption = sequelize.model('question_option');
const questionTemplate = sequelize.model('question_template');
const scheduleInstance = sequelize.model('schedule_instance');
const scheduleTemplate = sequelize.model('schedule_template');
const surveyInstance = sequelize.model('survey_instance');
const surveyTemplate = sequelize.model('survey_template');
const trial = sequelize.model('trial');
Expand All @@ -86,15 +78,12 @@ module.exports.setup = function (configuration) {
const joinTrialsAndSurveys = sequelize.model('join_trials_and_surveys');
const joinSurveysAndQuestions = sequelize.model('join_surveys_and_questions');
const joinQuestionsAndOptions = sequelize.model('join_questions_and_options');
const joinPatientsSurveysAndSchedules = sequelize.model('join_patients_surveys_and_schedules');

// establish relationships between tables

/* ===== ONE TO MANY ===== */
patient.hasMany(surveyInstance);
questionTemplate.hasMany(questionInstance);
scheduleTemplate.hasMany(scheduleInstance);
scheduleTemplate.hasMany(surveyTemplate);
surveyInstance.hasMany(questionInstance);
surveyTemplate.hasMany(surveyInstance);
trial.hasMany(patient);
Expand All @@ -110,11 +99,6 @@ module.exports.setup = function (configuration) {
questionTemplate.belongsToMany(questionOption, {through: joinQuestionsAndOptions});
questionOption.belongsToMany(questionTemplate, {through: joinQuestionsAndOptions});

patient.belongsToMany(scheduleInstance, {through: joinPatientsSurveysAndSchedules});
surveyTemplate.belongsToMany(scheduleInstance, {through: joinPatientsSurveysAndSchedules});
scheduleInstance.belongsToMany(patient, {through: joinPatientsSurveysAndSchedules});
scheduleInstance.belongsToMany(surveyTemplate, {through: joinPatientsSurveysAndSchedules});

// export configured sequelize to allow for access to database models
module.exports.sequelize = sequelize;
return sequelize;
Expand Down
20 changes: 0 additions & 20 deletions model/join-patients-surveys-and-schedules.js

This file was deleted.

28 changes: 0 additions & 28 deletions model/schedule-instance.js

This file was deleted.

44 changes: 0 additions & 44 deletions model/schedule-template.js

This file was deleted.

118 changes: 77 additions & 41 deletions view/template/patient.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -120,49 +120,85 @@
});
});
var scatterChartData = [
{
label: 'Compliance Chart',
strokeColor: '#A31515',
data: [
{
x: new Date('2011-04-11T11:45:00'),
y: 25
var scatterChartData = {
type: 'line',
data: {
datasets: [{
label: "Dataset with point data",
data: [{
x: "12/31/2014 06:00",
y: 1
}, {
x: "01/04/2015 13:00",
y: 3
}, {
x: "01/07/2015 01:15",
y: 5
}, {
x: "01/15/2015 01:15",
y: 7
}],
fill: false
}]
},
options: {
responsive: true,
scales: {
xAxes: [{
type: "time",
display: true,
time: {

This comment has been minimized.

Copy link
@sylvr3

sylvr3 Oct 26, 2015

Author Contributor

I changed the x axis to date-time format, yet they are showing up as decimals (see my screenshot). Wonder what I am missing... @ChristianMurphy

format: 'MM/DD/YYYY HH:mm',
},
{
x: new Date('2011-04-11T12:51:00'),
y: 28
},
{
x: new Date('2011-04-11T14:10:00'),
y: 22
},
{
x: new Date('2011-04-11T15:15:00'),
y: 18
},
{
x: new Date('2011-04-11T17:00:00'),
y: 25
},
{
x: new Date('2011-04-11T21:00:00'),
y: 24
},
{
x: new Date('2011-04-12T13:00:00'),
y: 24
scaleLabel: {
show: true,
labelString: 'Date'
}
}, ],
yAxes: [{
display: true,
scaleLabel: {
show: true,
labelString: 'value'
}
]
}];
}]
},
elements: {
line: {
tension: 0.3
}
},
}
};
window.onload = function() {
var ctx = document.getElementById("scatterChart").getContext("2d");
var myDateLineChart = new Chart(ctx).Scatter(scatterChartData, {
bezierCurve: true,
showTooltips: true,
scaleShowHorizontalLines: true,
scaleShowLabels: true,
scaleType: "date",
scaleLabel: "<%=value%>°C"
});
window.myScatter = Chart.Scatter(ctx, {
data: scatterChartData,
options: {
scales: {
xAxes: [{
position: 'top',
gridLines: {
zeroLineColor: "rgba(0,255,0,1)"
},
scaleLabel: {
show: true,
labelString: 'Patient ID'
}
}],
yAxes: [{
position: 'right',
gridLines: {
zeroLineColor: "rgba(0,255,0,1)"
},
scaleLabel: {
show: true,
labelString: 'Compliance Time Series'
}
}]
}
}
});
};
</script>

0 comments on commit 07bdf0a

Please sign in to comment.