Chart.js Radar background color of background












-1














anyone did know if there is possible to change background area of a Radar like the image, i poster?enter image description here










share|improve this question



























    -1














    anyone did know if there is possible to change background area of a Radar like the image, i poster?enter image description here










    share|improve this question

























      -1












      -1








      -1







      anyone did know if there is possible to change background area of a Radar like the image, i poster?enter image description here










      share|improve this question













      anyone did know if there is possible to change background area of a Radar like the image, i poster?enter image description here







      javascript charts chart.js






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 13 at 14:42









      user3699954

      113




      113
























          2 Answers
          2






          active

          oldest

          votes


















          1














          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






          share|improve this answer































            0














            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.






            share|improve this answer





















            • 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











            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
            });


            }
            });














            draft saved

            draft discarded


















            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









            1














            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






            share|improve this answer




























              1














              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






              share|improve this answer


























                1












                1








                1






                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






                share|improve this answer














                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







                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited Nov 19 at 0:22

























                answered Nov 19 at 0:07









                cramirez

                112




                112

























                    0














                    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.






                    share|improve this answer





















                    • 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
















                    0














                    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.






                    share|improve this answer





















                    • 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














                    0












                    0








                    0






                    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.






                    share|improve this answer












                    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.







                    share|improve this answer












                    share|improve this answer



                    share|improve this answer










                    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


















                    • 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


















                    draft saved

                    draft discarded




















































                    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.




                    draft saved


                    draft discarded














                    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





















































                    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







                    Popular posts from this blog

                    Guess what letter conforming each word

                    Port of Spain

                    Run scheduled task as local user group (not BUILTIN)