Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable centered label drawing for doughnut controllers #825

Merged
merged 42 commits into from
Oct 10, 2024
Merged
Show file tree
Hide file tree
Changes from 41 commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
050d45e
Enable centered label drawing for doughnut controllers
stockiNail Jan 2, 2023
bffc452
InnerLabel uses the label annotation
stockiNail Jan 2, 2023
00fa4ee
moves code in afterUpdate hook
stockiNail Jan 2, 2023
93e4816
adds listeners to events
stockiNail Jan 2, 2023
a2001f1
changes context type for innerlabel
stockiNail Jan 2, 2023
5fb097d
moves to a specific element for doughnut inner label
stockiNail Jan 3, 2023
0fa5b9e
removes specific context type for innerlabel
stockiNail Jan 3, 2023
6cbbf43
fixes returned properties when there is not any doughnut controller
stockiNail Jan 3, 2023
b215785
removes inner label plugin and all managed by annotaiton one
stockiNail Jan 3, 2023
33be0fe
adds js doc and fix some CC issues
stockiNail Jan 3, 2023
408de06
improves controller retriever
stockiNail Jan 3, 2023
5181eb7
creates helpers.callout
stockiNail Jan 4, 2023
2699fb6
fixes visibility check on elements
stockiNail Jan 4, 2023
a6a76cc
test cases
stockiNail Jan 4, 2023
7e214a7
improves filter on array and more tests
stockiNail Jan 4, 2023
6bc3477
types def
stockiNail Jan 4, 2023
dcf09b6
add documentation
stockiNail Jan 4, 2023
102b1c9
fix lint
stockiNail Jan 4, 2023
1e1f0f0
add samples
stockiNail Jan 5, 2023
4c67805
fixes animations and options
stockiNail Jan 5, 2023
21b9e13
no extension from label and background not a box but arc
stockiNail Jan 6, 2023
4eade88
aply some reviews
stockiNail Jan 9, 2023
fb32684
lint
stockiNail Jan 9, 2023
7b92d98
fixes test cases
stockiNail Jan 9, 2023
2332455
fixes color animation
stockiNail Jan 9, 2023
9817696
fixes font and colors options as indexable
stockiNail Jan 9, 2023
89e2458
adds new test cases for background
stockiNail Jan 9, 2023
fe411e9
fixes types
stockiNail Jan 9, 2023
87f2e07
fixes docs and samples
stockiNail Jan 9, 2023
829ff30
CC and color animations
stockiNail Jan 9, 2023
198d964
change doc about animations
stockiNail Jan 9, 2023
a82ede0
Merge remote-tracking branch 'origin/master' into innerLabelProto
stockiNail Jan 31, 2023
cec5196
Merge remote-tracking branch 'origin/master' into innerLabelProto
stockiNail Feb 27, 2023
b468ef6
apply new features coming from other PRs after merging
stockiNail Feb 27, 2023
4bb7ecd
adds test cases for init animation
stockiNail Feb 27, 2023
b2cc907
apply review
stockiNail Feb 28, 2023
a359625
Merge remote-tracking branch 'origin/master' into innerLabelProto
stockiNail May 9, 2023
91ff42d
Merge remote-tracking branch 'origin/master' into innerLabelProto
stockiNail May 16, 2023
4d592cd
fix lineHeight on multiple font when size must be updated by fit ratio
stockiNail May 22, 2023
1701b84
Merge branch 'master' into innerLabelProto
stockiNail Sep 20, 2024
26a5ca1
add hitTolerance
stockiNail Sep 20, 2024
a51cf39
apply review
stockiNail Oct 7, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ For Chart.js 2.4.0 to 2.9.x support, use [version 0.5.7 of this plugin](https://

This plugin draws lines, boxes, points, labels, polygons and ellipses on the chart area.

Annotations work with line, bar, scatter and bubble charts that use linear, logarithmic, time, or category scales. Annotations will not work on any chart that does not have two or more axes, including pie, radar, and polar area charts.
Annotations work with line, bar, scatter and bubble charts that use linear, logarithmic, time, or category scales.
Furthermore you can use a doughnut label annotation which can be used to add contents (text, image, canvas) in the middle area of the doughnut charts.

![Example Screenshot](docs/guide/banner.png)

Expand Down
243 changes: 243 additions & 0 deletions docs/.vuepress/config.js
stockiNail marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,243 @@
const path = require('path');
const docsVersion = "VERSION";
const base = process.env.NODE_ENV === "development" ? '/chartjs-plugin-annotation/master/' : `/chartjs-plugin-annotation/${docsVersion}/`;

module.exports = {
dest: 'dist/docs',
title: 'chartjs-plugin-annotation',
description: 'Annotations for Chart.js',
theme: 'chartjs',
base,
head: [
['link', {rel: 'icon', href: '/favicon.png'}],
],
plugins: [
['flexsearch'],
['redirect', {
redirectors: [
// Default sample page when accessing /samples.
{base: '/samples', alternative: ['intro']},
],
}],
[
'vuepress-plugin-typedoc',
{
entryPoints: ['../../types/index.d.ts'],
hideInPageTOC: true,
tsconfig: 'tsconfig.json',
sidebar: {
fullNames: true,
parentCategory: 'API',
},
},
],
['@simonbrunel/vuepress-plugin-versions', {
filters: {
suffix: (tag) => tag ? ` (${tag})` : '',
title: (v, vars) => window.location.href.includes('master') ? 'Development (master)' : v + (vars.tag ? ` (${tag})` : ''),
},
menu: {
text: '{{version|title}}',
items: [
{
text: 'Documentation',
items: [
{
text: 'Development (master)',
link: '/chartjs-plugin-annotation/master/',
target: '_self',
},
{
type: 'versions',
text: '{{version}}{{tag|suffix}}',
link: '/chartjs-plugin-annotation/{{version}}/',
exclude: /^[0]\.[0-4]\./,
group: 'minor',
target: '_self',
}
]
},
{
text: 'Release notes (5 latest)',
items: [
{
type: 'versions',
limit: 5,
target: '_blank',
group: 'patch',
link: 'https://github.com/chartjs/chartjs-plugin-annotation/releases/tag/v{{version}}'
}
]
}
]
},
}],
],
chainWebpack(config) {
config.module
.rule('chart.js')
.include.add(path.resolve('node_modules/chart.js')).end()
.use('babel-loader')
.loader('babel-loader')
.options({
presets: ['@babel/preset-env']
})
.end();
},
markdown: {
extendMarkdown: md => {
md.use(require('markdown-it-include'), path.resolve(__dirname, '../'));
}
},
themeConfig: {
repo: 'chartjs/chartjs-plugin-annotation',
logo: '/favicon.png',
lastUpdated: 'Last Updated',
searchPlaceholder: 'Search...',
editLinks: true,
docsDir: 'docs',
chart: {
imports: [
['scripts/register.js'],
['scripts/defaults.js'],
['scripts/utils.js', 'Utils'],
]
},
nav: [
{text: 'Home', link: '/'},
{text: 'API', link: '/api/'},
{text: 'Guide', link: '/guide/'},
{text: 'Samples', link: '/samples/'},
],
sidebar: {
'/api/': {
title: 'API'
},
'/guide/': [
'',
'integration',
'usage',
'options',
'configuration',
{
title: 'Annotations',
collapsable: false,
children: [
'types/box',
'types/ellipse',
'types/label',
'types/line',
'types/point',
'types/polygon',
'types/doughnutLabel'
]
},
'migrationV1',
'migrationV2'
],
'/samples/': [
'intro',
{
title: 'Box annotations',
children: [
'box/basic',
'box/quarters',
'box/disclosure',
'box/canvas',
'box/image',
'box/initAnim',
'box/gradient',
]
},
{
title: 'Ellipse annotations',
children: [
'ellipse/basic',
'ellipse/rotation',
'ellipse/label',
'ellipse/image',
]
},
{
title: 'Label annotations',
children: [
'label/basic',
'label/point',
'label/callout',
'label/canvas',
'label/image',
'label/innerChart',
'label/lowerUpper',
'label/fontsColors',
'label/autoscaling'
]
},
{
title: 'Line annotations',
children: [
'line/basic',
'line/curve',
'line/lowerUpper',
'line/limited',
'line/average',
'line/standardDeviation',
'line/callout',
'line/visibility',
'line/labelVisibility',
'line/canvas',
'line/image',
'line/datasetBars',
'line/animation',
'line/hook',
]
},
{
title: 'Point annotations',
children: [
'point/basic',
'point/combined',
'point/outsideChartArea',
'point/shadow',
'point/initAnim',
]
},
{
title: 'Polygon annotations',
children: [
'polygon/basic',
'polygon/stop',
'polygon/outsideChartArea',
'polygon/shadow',
]
},
{
title: 'Doughnut label annotations',
children: [
'doughnutLabel/basic',
'doughnutLabel/canvas',
'doughnutLabel/image',
'doughnutLabel/gauge',
'doughnutLabel/background',
]
},
{
title: 'Charts',
children: [
'charts/bar',
'charts/line',
],
},
{
title: 'Interaction',
children: [
'interaction/interaction',
'interaction/dragging',
'interaction/selection',
'interaction/cartesianplane',
],
},
'utils',
]
}
}
};
13 changes: 12 additions & 1 deletion docs/.vuepress/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,8 @@ export default defineConfig({
'types/label',
'types/line',
'types/point',
'types/polygon'
'types/polygon',
'types/doughnutLabel'
]
},
'developers',
Expand Down Expand Up @@ -220,6 +221,16 @@ export default defineConfig({
'polygon/shadow'
]
},
{
title: 'Doughnut label annotations',
children: [
'doughnutLabel/basic',
'doughnutLabel/canvas',
'doughnutLabel/image',
'doughnutLabel/gauge',
'doughnutLabel/background',
]
},
{
title: 'Charts',
children: [
Expand Down
1 change: 1 addition & 0 deletions docs/diagrams/elementDoughnutLabelProps.drawio
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<mxfile host="Electron" modified="2023-01-04T15:27:51.065Z" agent="5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) draw.io/20.6.2 Chrome/106.0.5249.199 Electron/21.3.3 Safari/537.36" etag="UwpRt7ZZ2I8QNyQM25Nf" version="20.6.2" type="device"><diagram id="EVLCtf8sz0nmjKRDlPg8" name="Page-1">7ZfZjpswFIafhstUYLMkl4VZoqqVKkXVtFeVJzhg1XCocRqSp68NJonjjKaVMotGw03w7+Pt+31s4uGs6m4FacovkFPuIT/vPHzlIRT401j9aGU7KNNgOgiFYLkJOggLtqNjS6OuWU5bK1ACcMkaW1xCXdOltDQiBGzssBVwe9SGFNQRFkvCXfWO5bI0q0DJQZ9TVpTjyEE8G2oqMgablbQlyWFzJOFrD2cCQA5vVZdRruGNXIZ2Nw/U7icmaC3/pUF6t5vHP3dh1szR76+Lifz86dvE9PKH8LVZsJms3I4EBKzrnOpOfA+nm5JJumjIUtdulOdKK2XFVSlQr+6kxhGokLQ7kswkbylUVIqtCjG1yDfAzI5BoSlvDvxxbLTyiP2+ITGeF/u+D1jUiyHzH5TQ45RUL2pL0scJkbYZ9umKdZpqumKcZ8BB9B3h4bkMSpwkHyILJsZ75Qhn5MKMnggldlB2Hsq2Dk+1QmmDE7RlO3LfB+idSNYS2uG86LlyVtTqfalwUcUy1ZiYSuSPpqJiea4bpw2wWvbrilIvujqxoIZaB7VSwC96ItqpsIJamgMLhbqJ8pzVRQpSQqXE8DImBslJPvhuPkRn0iF8qmwIHQsH5t+Vkfok7gs/3h19+ISbnTg6O5eUwew5TY3cvEQ6Md2T7t3H0ccI2z6GZ26q5DlNjB0Th5m8GgvV/XbTP6/KRxzal+T+k+2lfEwcH82wb9lIAZJIBnoSk5l/obsztjMUn3F2ehlnVfHwLd/XHf0jwtd/AQ==</diagram></mxfile>
4 changes: 3 additions & 1 deletion docs/guide/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@ const options = {
| Name | Option | Value
| ---- | ---- | ----
| `numbers` | `properties` | `['x', 'y', 'x2', 'y2', 'width', 'height', 'centerX', 'centerY', 'pointX', 'pointY', 'radius']`
| `numbers` | `type` | `number`
| `numbers` | `type` | `'number'`
| `colors` | `properties` | `['backgroundColor', 'borderColor']`
| `colors` | `type` | `'color'`

## Common

Expand Down
6 changes: 5 additions & 1 deletion docs/guide/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@ This plugin needs to be registered. It does not function as inline plugin.

An annotation plugin for Chart.js >= 4.0.0

This plugin draws lines, boxes, labels, points, polygons and ellipses on the chart area. Annotations work with line, bar, scatter and bubble charts that use linear, logarithmic, time, or category scales. Annotations will not work on any chart that does not have exactly two axes, including pie, radar, and polar area charts.
This plugin draws lines, boxes, labels, points, polygons and ellipses on the chart area. Annotations work with line, bar, scatter and bubble charts that use linear, logarithmic, time, or category scales.

Furthermore you can use a doughnut label annotation which can be used to add contents (text, image, canvas) in the middle area of the doughnut charts.

Annotations will not work on any chart that does not have exactly two axes, including pie, radar, and polar area charts.

![Banner](./banner.png)

Expand Down
Loading
Loading