New doughnutLabel does not take spacing into account
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 35/100
- Tipo di issue
- Bug
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Ferma
- Stack tecnologico
- chart.js, javascript
- Ambito
- data-visualization, frontend
Direzione di ricerca
Inizia leggendo src/types/doughnutLabel.js nelle righe collegate relative al calcolo del raggio, a drawArc e a getFitRatio. Riproduci l’esempio di spaziatura e il caso in cui spacing supera innerRadius; il lavoro è completato quando spacing limita anche la dimensione della label e uno spacing eccessivo non produce più un raggio dell’arco Canvas negativo.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
In #825, a centered doughnut label annotation was added, though the spacing option does not seem to reduce the label size, only the border and background sizes.
Ideally, I want to maximize the font size for the center label, while still keeping some padding around the label, so it doesn't hug the inside of the doughnut chart like it does now. Before the doughnutLabel annotation, I used my own plugin based on this StackOverflow answer, and there I can just add some padding around the label.
For example, with the text in blue, the background color in green, and in this case a spacing of 10, results in the background correctly getting padding, but the label is still the same size as if there was no spacing.
Additional bug: when increasing the spacing parameter until it becomes bigger than the innerRadius, results in the following error being thrown from the drawArc function:
IndexSizeError: Failed to execute 'arc' on 'CanvasRenderingContext2D': The radius provided (-38.5) is negative.
As used here (with _radius):
https://github.com/chartjs/chartjs-plugin-annotation/blob/0d6246df894560217ed2bf5ce1ded050b400f3df/src/types/doughnutLabel.js#L188
Caused by this subtraction:
https://github.com/chartjs/chartjs-plugin-annotation/blob/0d6246df894560217ed2bf5ce1ded050b400f3df/src/types/doughnutLabel.js#L139
On another note, this function:
https://github.com/chartjs/chartjs-plugin-annotation/blob/0d6246df894560217ed2bf5ce1ded050b400f3df/src/types/doughnutLabel.js#L157-L160
could also use the built-in Math.hypot function, like so:
function getFitRatio({width, height}, radius) {
return (radius * 2) / Math.hypot(width, height);
}
- Lingua principale
- JavaScript
- Stelle
- 623
- Fork
- 377
- Merge medio
- 11h 20m
- PR unite (30g)
- 7
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di chartjs/chartjs-plugin-annotation
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 48/100
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 35/100
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 35/100
-
TypeScript type issuesForse già presa @joshkel l’ha presa 439 giorni fa. Aperta
Difficoltà 4/5 3-5 giorni Idoneità per principianti 38/100
Tutte le issue di chartjs/chartjs-plugin-annotation
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
processing/p5.sound.js#123 ·
-
Difficoltà 1/5 1-3 ore Idoneità per principianti 82/100
PhilflowIO/dav-mcp#146 ·
I maintainer di solito rispondono entro 1 giorno
-
good first issue hacktoberfest
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
Tanishq964/trail-kit.#4 ·
-
Request: <brand-name>Apertanew icon permissions in review
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
simple-icons/simple-icons#15067 ·
I maintainer di solito rispondono entro 1 giorno
-
status: needs triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
mastra-ai/mastra#26562 · 1 commento · 1 reazione ·
I maintainer di solito rispondono entro 1 giorno