Chart.js Radar background color of background
anyone did know if there is possible to change background area of a Radar like the image, i poster?
javascript charts chart.js
add a comment |
anyone did know if there is possible to change background area of a Radar like the image, i poster?
javascript charts chart.js
add a comment |
anyone did know if there is possible to change background area of a Radar like the image, i poster?
javascript charts chart.js
anyone did know if there is possible to change background area of a Radar like the image, i poster?
javascript charts chart.js
javascript charts chart.js
asked Nov 13 at 14:42
user3699954
113
113
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
I had the same issue, looks like the documentations isn't friendly for these cases, I based my solution on these examples:
- https://github.com/chartjs/Chart.js/issues/3956#issuecomment-287080840
- https://www.html5canvastutorials.com/tutorials/html5-canvas-circles/
My options
object looks like this:
options: {
...
chartArea: { backgroundColor: 'red' },
...
}
I used the hook function beforeDraw
in order to draw the background-color behind the chart and it looks like this:
Chart.pluginService.register({
beforeDraw: chart => {
const { ctx, scale, config } = chart
const { xCenter, yCenter, drawingArea: radius } = scale
ctx.save()
ctx.arc(xCenter, yCenter, radius, 0, Math.PI * 2)
ctx.fillStyle = config.options.chartArea.backgroundColor
ctx.fill()
ctx.restore()
}
});
In beforeDraw
function you can catch options
object with your custom attributes.
You can check full list of hooks here
add a comment |
I assume you're using this module from the chart.js library
https://www.chartjs.org/docs/latest/charts/radar.html
The documentation says you can change the color specifying it on the datasets properties.
data: {
labels: ['Running', 'Swimming', 'Eating', 'Cycling'],
datasets: [{
data: [20, 10, 4, 2],
backgroundColor: 'red'
}]
}
Hope that helps.
Hi tks for your aswer, but I need to color not background of chart but area around chart
– user3699954
Nov 14 at 14:48
Could you add part of your code ? a JSFiddle could help a lot.
– Archagy
Nov 15 at 14:39
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53283486%2fchart-js-radar-background-color-of-background%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
I had the same issue, looks like the documentations isn't friendly for these cases, I based my solution on these examples:
- https://github.com/chartjs/Chart.js/issues/3956#issuecomment-287080840
- https://www.html5canvastutorials.com/tutorials/html5-canvas-circles/
My options
object looks like this:
options: {
...
chartArea: { backgroundColor: 'red' },
...
}
I used the hook function beforeDraw
in order to draw the background-color behind the chart and it looks like this:
Chart.pluginService.register({
beforeDraw: chart => {
const { ctx, scale, config } = chart
const { xCenter, yCenter, drawingArea: radius } = scale
ctx.save()
ctx.arc(xCenter, yCenter, radius, 0, Math.PI * 2)
ctx.fillStyle = config.options.chartArea.backgroundColor
ctx.fill()
ctx.restore()
}
});
In beforeDraw
function you can catch options
object with your custom attributes.
You can check full list of hooks here
add a comment |
I had the same issue, looks like the documentations isn't friendly for these cases, I based my solution on these examples:
- https://github.com/chartjs/Chart.js/issues/3956#issuecomment-287080840
- https://www.html5canvastutorials.com/tutorials/html5-canvas-circles/
My options
object looks like this:
options: {
...
chartArea: { backgroundColor: 'red' },
...
}
I used the hook function beforeDraw
in order to draw the background-color behind the chart and it looks like this:
Chart.pluginService.register({
beforeDraw: chart => {
const { ctx, scale, config } = chart
const { xCenter, yCenter, drawingArea: radius } = scale
ctx.save()
ctx.arc(xCenter, yCenter, radius, 0, Math.PI * 2)
ctx.fillStyle = config.options.chartArea.backgroundColor
ctx.fill()
ctx.restore()
}
});
In beforeDraw
function you can catch options
object with your custom attributes.
You can check full list of hooks here
add a comment |
I had the same issue, looks like the documentations isn't friendly for these cases, I based my solution on these examples:
- https://github.com/chartjs/Chart.js/issues/3956#issuecomment-287080840
- https://www.html5canvastutorials.com/tutorials/html5-canvas-circles/
My options
object looks like this:
options: {
...
chartArea: { backgroundColor: 'red' },
...
}
I used the hook function beforeDraw
in order to draw the background-color behind the chart and it looks like this:
Chart.pluginService.register({
beforeDraw: chart => {
const { ctx, scale, config } = chart
const { xCenter, yCenter, drawingArea: radius } = scale
ctx.save()
ctx.arc(xCenter, yCenter, radius, 0, Math.PI * 2)
ctx.fillStyle = config.options.chartArea.backgroundColor
ctx.fill()
ctx.restore()
}
});
In beforeDraw
function you can catch options
object with your custom attributes.
You can check full list of hooks here
I had the same issue, looks like the documentations isn't friendly for these cases, I based my solution on these examples:
- https://github.com/chartjs/Chart.js/issues/3956#issuecomment-287080840
- https://www.html5canvastutorials.com/tutorials/html5-canvas-circles/
My options
object looks like this:
options: {
...
chartArea: { backgroundColor: 'red' },
...
}
I used the hook function beforeDraw
in order to draw the background-color behind the chart and it looks like this:
Chart.pluginService.register({
beforeDraw: chart => {
const { ctx, scale, config } = chart
const { xCenter, yCenter, drawingArea: radius } = scale
ctx.save()
ctx.arc(xCenter, yCenter, radius, 0, Math.PI * 2)
ctx.fillStyle = config.options.chartArea.backgroundColor
ctx.fill()
ctx.restore()
}
});
In beforeDraw
function you can catch options
object with your custom attributes.
You can check full list of hooks here
edited Nov 19 at 0:22
answered Nov 19 at 0:07
cramirez
112
112
add a comment |
add a comment |
I assume you're using this module from the chart.js library
https://www.chartjs.org/docs/latest/charts/radar.html
The documentation says you can change the color specifying it on the datasets properties.
data: {
labels: ['Running', 'Swimming', 'Eating', 'Cycling'],
datasets: [{
data: [20, 10, 4, 2],
backgroundColor: 'red'
}]
}
Hope that helps.
Hi tks for your aswer, but I need to color not background of chart but area around chart
– user3699954
Nov 14 at 14:48
Could you add part of your code ? a JSFiddle could help a lot.
– Archagy
Nov 15 at 14:39
add a comment |
I assume you're using this module from the chart.js library
https://www.chartjs.org/docs/latest/charts/radar.html
The documentation says you can change the color specifying it on the datasets properties.
data: {
labels: ['Running', 'Swimming', 'Eating', 'Cycling'],
datasets: [{
data: [20, 10, 4, 2],
backgroundColor: 'red'
}]
}
Hope that helps.
Hi tks for your aswer, but I need to color not background of chart but area around chart
– user3699954
Nov 14 at 14:48
Could you add part of your code ? a JSFiddle could help a lot.
– Archagy
Nov 15 at 14:39
add a comment |
I assume you're using this module from the chart.js library
https://www.chartjs.org/docs/latest/charts/radar.html
The documentation says you can change the color specifying it on the datasets properties.
data: {
labels: ['Running', 'Swimming', 'Eating', 'Cycling'],
datasets: [{
data: [20, 10, 4, 2],
backgroundColor: 'red'
}]
}
Hope that helps.
I assume you're using this module from the chart.js library
https://www.chartjs.org/docs/latest/charts/radar.html
The documentation says you can change the color specifying it on the datasets properties.
data: {
labels: ['Running', 'Swimming', 'Eating', 'Cycling'],
datasets: [{
data: [20, 10, 4, 2],
backgroundColor: 'red'
}]
}
Hope that helps.
answered Nov 13 at 14:51
Archagy
35110
35110
Hi tks for your aswer, but I need to color not background of chart but area around chart
– user3699954
Nov 14 at 14:48
Could you add part of your code ? a JSFiddle could help a lot.
– Archagy
Nov 15 at 14:39
add a comment |
Hi tks for your aswer, but I need to color not background of chart but area around chart
– user3699954
Nov 14 at 14:48
Could you add part of your code ? a JSFiddle could help a lot.
– Archagy
Nov 15 at 14:39
Hi tks for your aswer, but I need to color not background of chart but area around chart
– user3699954
Nov 14 at 14:48
Hi tks for your aswer, but I need to color not background of chart but area around chart
– user3699954
Nov 14 at 14:48
Could you add part of your code ? a JSFiddle could help a lot.
– Archagy
Nov 15 at 14:39
Could you add part of your code ? a JSFiddle could help a lot.
– Archagy
Nov 15 at 14:39
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53283486%2fchart-js-radar-background-color-of-background%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown