Public
Edited
Jan 22, 2023
Fork of Untitled
1 star
Insert cell
Insert cell
data.filter(d => d.USUBJID === "01-701-1015").map(d => ([d.AVISITN, d.AVAL]))
Insert cell
Insert cell
Insert cell
{
var ctx = document.getElementById('myChart');

let visits = unique(data, "AVISIT")
let nvisits = unique(data, "AVISITN")
let subjects = unique(data, 'USUBJID')

var chart = new Chart(ctx, {
// The type of chart we want to create
type: 'line', // also try bar or other graph types

// The data for our dataset
data: {
labels: nvisits,
// Information about the dataset
datasets: subjects.map((subj) => {
return ({
label: data.filter((d) => d.USUBJID === subj)[0].TRTA,
backgroundColor: color_switch(data.filter((d) => d.USUBJID === subj)[0].TRTA),
borderColor: color_switch(data.filter((d) => d.USUBJID === subj)[0].TRTA),
data: data.filter(d => d.USUBJID === "01-701-1015").map(d => ([d.AVISITN, d.AVAL]))
})
})
},

// Configuration options
options: {
layout: {
padding: 10,
},
title: {
display: true,
text: 'Precipitation in Toronto'
},
/*
scales: {
x: {
ticks: {
callback: function(value, index, ticks) {
return `${nvisits[index].visits}`
}
}
}
}
*/
}
})
return chart

}
Insert cell
Insert cell
Insert cell
Insert cell
Chart = require('chart.js@4.2.0/dist/chart.umd.js')
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more