generated from jackyzha0/quartz
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Affected files: content/.obsidian/plugins/recent-files-obsidian/data.json content/.obsidian/workspace.json content/_templates/default-note.md content/attachments/chart-js-example-plugin.png content/chart-js/Chart.js.md content/chart-js/Getting Started with Chart.js.md content/chart-js/Plugins of Chart.js.md content/chart-js/Tree-shaking of Chart.js.md content/chart-js/react-chartjs-2.md
- Loading branch information
Showing
9 changed files
with
179 additions
and
126 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,13 @@ | ||
--- | ||
title: <% tp.file.title %> | ||
draft: false | ||
date: 2023-09-13 18:23 | ||
date: 2023-10-03 10:52 | ||
tags: | ||
- reading | ||
- learning | ||
--- | ||
|
||
> [!tldr] TL;DR | ||
> Write some tldr | ||
write some details or insights | ||
write some quick thoughts | ||
|
||
> [!info] References | ||
> - put some references |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
--- | ||
title: Plugins of Chart.js | ||
draft: false | ||
date: 2023-10-03 11:03 | ||
tags: | ||
- learning | ||
- chart-js | ||
--- | ||
|
||
Another way to customize the chart is by using plugins. You can employ plugins [created by other developers](https://github.com/chartjs/awesome#plugins) or create your own. The tutorial demonstrates how to create an ad-hoc one that adds a border to the chart. | ||
```js title="src/draw.js" {1-18,24,31-38} | ||
const chartAreaBorder = { | ||
id: "chartAreaBorder", | ||
|
||
beforeDraw(chart, args, options) { | ||
const { | ||
ctx, | ||
chartArea: { left, top, width, height }, | ||
} = chart; | ||
|
||
ctx.save(); | ||
ctx.strokeStyle = options.borderColor; | ||
ctx.lineWidth = options.borderWidth; | ||
ctx.setLineDash(options.borderDash || []); | ||
ctx.lineDashOffset = options.borderDashOffset; | ||
ctx.strokeRect(left, top, width, height); | ||
ctx.restore(); | ||
}, | ||
}; | ||
|
||
(async function () { | ||
const data = []; | ||
new Chart(document.getElementById("draw"), { | ||
type: "bar", | ||
plugins: [chartAreaBorder], | ||
options: { | ||
aspectRatio: 1, | ||
scales: { | ||
x: { stacked: true }, | ||
y: { max: 40, ticks: { callback: (value) => `${value} times` } }, | ||
}, | ||
plugins: { | ||
chartAreaBorder: { | ||
borderColor: "red", | ||
borderWidth: 2, | ||
borderDash: [5, 5], | ||
borderDashOffset: 2, | ||
}, | ||
}, | ||
}, | ||
})(); | ||
``` | ||
![[chart-js-example-plugin.png]] | ||
> [!info] References | ||
> - put some references |
Oops, something went wrong.