One plugin for every chart in your vault. Make one from a Bases view, a code block or a script, with less code than other chart plugins need and no second one beside it.
Install it from Obsidian's community plugins, or see Installation for manual and beta installs.
| Way | Use it when | Needs |
|---|---|---|
| Bases view | the numbers are note properties, like books counted by status or hours summed by project | Bases, built into Obsidian |
chart code block |
the numbers are in no note, so you type them in | nothing else |
| Script function | the numbers have to be worked out first, like notes created this month counted by tag | a plugin that runs JavaScript in notes, such as Dataview |
The smallest chart is a code block:
```chart
type: line
labels: [Jan, Feb, Mar, Apr]
series:
- title: Pages read
data: [320, 450, 280, 510]
```
Notes created this month counted by tag, the top 10 as horizontal bars with the count on each, from counts, an object of tag and count. Charts' renderChart leaves the sorting, theme colors, counts on the bars and bar thickness to you. With Chartwork it is one call:
window.chartwork.render(dv.container, {
kind: "bar",
horizontal: true,
labels: Object.keys(counts),
series: [{ name: "Notes", values: Object.values(counts) }],
sort: "value",
topN: 10,
}, dv.component);
renderChart, 45 linesconst top = Object.entries(counts).sort((a, b) => b[1] - a[1]).slice(0, 10);
// renderChart sets no colors, and Chart.js's grey disappears on a dark theme
const css = getComputedStyle(dv.container);
const text = css.getPropertyValue("--text-normal").trim();
const grid = css.getPropertyValue("--background-modifier-border").trim();
const bar = css.getPropertyValue("--interactive-accent").trim();
// Chart.js prints no values on bars by itself
const valueLabels = {
id: "valueLabels",
afterDatasetsDraw(chart) {
const { ctx } = chart;
ctx.save();
ctx.font = "bold 12px sans-serif";
ctx.fillStyle = text;
ctx.textBaseline = "middle";
chart.getDatasetMeta(0).data.forEach((el, i) => {
ctx.fillText(chart.data.datasets[0].data[i], el.x + 6, el.y);
});
ctx.restore();
},
};
window.renderChart({
type: "bar",
plugins: [valueLabels],
data: {
labels: top.map(([tag]) => tag),
datasets: [{
label: "Notes",
data: top.map(([, n]) => n),
backgroundColor: bar,
}],
},
options: {
indexAxis: "y",
// Without this the bars get thinner as tags are added
aspectRatio: 600 / (top.length * 28 + 60),
layout: { padding: { right: 24 } },
plugins: { legend: { display: false } },
scales: {
x: {
beginAtZero: true,
ticks: { color: text, precision: 0 },
grid: { color: grid },
},
y: { ticks: { color: text }, grid: { display: false } },
},
},
}, dv.container);
Chartwork runs on Chart.js 4 and bundles time axes, sankey diagrams and annotations for it. A script can pass it a full Chart.js config. This one draws half a year of pages read per day, a 7-day average over it, a shaded holiday and a target line (its script):
More in Beyond the basics.
Notes written for Charts work without changes and draw on Chart.js 4, so you no longer need Charts. The Bases view counts notes and adds up values by category or by day, week, month or year. That does the job of Bases Charts and most of what people use Tracker for. Tracker's month calendar and streak summaries, and Charts' chart builder and image export, are not in Chartwork.
chart block names, and, for the check command, your notes. It writes nothing to the vault. A Bases view's options are saved into its .base file by Bases itself.