Custom colors when generating a pie chart from JSON











up vote
1
down vote

favorite












I'm trying to create a pie chart with a custom set of colours using Am4Charts and the createFromConfig method.



I've followed the tutorial here but the chart keeps appearing with it's default color set.



Here is a sample of the JSON I've tried:



"innerRadius": 100,
"colors": {"list": ["#ff0000", "#00ff00", "#0000ff" ]},
"data": {
"0": {
"pot": "Within 8 days",
"value": "£111,119.70",
},
"1": {
"pot": "9 - 17 days",
"value": "£225,537.73"
},
"2": {
"pot": "18+ days",
"value": "£720,279.85"
}
},
"legend": ,
"xAxes": [
{
"type": "CategoryAxis",
"title": {
"text": "pot"
},
"dataFields": {
"category": "pot",
"title": {
"text": "Month"
}
},
"renderer": {
"labels": {
"rotation": 190,
"verticalCenter": "middle",
"horizontalCenter": "left"
}
}
}
],

"series": [
{
"type": "PieSeries",
"dataFields": {
"value": "value",
"category": "pot"
},
"ticks": {
"disabled": true
},
"labels": {
"disabled": true
},

}
],


Can somebody see where I've gone wrong?










share|improve this question




























    up vote
    1
    down vote

    favorite












    I'm trying to create a pie chart with a custom set of colours using Am4Charts and the createFromConfig method.



    I've followed the tutorial here but the chart keeps appearing with it's default color set.



    Here is a sample of the JSON I've tried:



    "innerRadius": 100,
    "colors": {"list": ["#ff0000", "#00ff00", "#0000ff" ]},
    "data": {
    "0": {
    "pot": "Within 8 days",
    "value": "£111,119.70",
    },
    "1": {
    "pot": "9 - 17 days",
    "value": "£225,537.73"
    },
    "2": {
    "pot": "18+ days",
    "value": "£720,279.85"
    }
    },
    "legend": ,
    "xAxes": [
    {
    "type": "CategoryAxis",
    "title": {
    "text": "pot"
    },
    "dataFields": {
    "category": "pot",
    "title": {
    "text": "Month"
    }
    },
    "renderer": {
    "labels": {
    "rotation": 190,
    "verticalCenter": "middle",
    "horizontalCenter": "left"
    }
    }
    }
    ],

    "series": [
    {
    "type": "PieSeries",
    "dataFields": {
    "value": "value",
    "category": "pot"
    },
    "ticks": {
    "disabled": true
    },
    "labels": {
    "disabled": true
    },

    }
    ],


    Can somebody see where I've gone wrong?










    share|improve this question


























      up vote
      1
      down vote

      favorite









      up vote
      1
      down vote

      favorite











      I'm trying to create a pie chart with a custom set of colours using Am4Charts and the createFromConfig method.



      I've followed the tutorial here but the chart keeps appearing with it's default color set.



      Here is a sample of the JSON I've tried:



      "innerRadius": 100,
      "colors": {"list": ["#ff0000", "#00ff00", "#0000ff" ]},
      "data": {
      "0": {
      "pot": "Within 8 days",
      "value": "£111,119.70",
      },
      "1": {
      "pot": "9 - 17 days",
      "value": "£225,537.73"
      },
      "2": {
      "pot": "18+ days",
      "value": "£720,279.85"
      }
      },
      "legend": ,
      "xAxes": [
      {
      "type": "CategoryAxis",
      "title": {
      "text": "pot"
      },
      "dataFields": {
      "category": "pot",
      "title": {
      "text": "Month"
      }
      },
      "renderer": {
      "labels": {
      "rotation": 190,
      "verticalCenter": "middle",
      "horizontalCenter": "left"
      }
      }
      }
      ],

      "series": [
      {
      "type": "PieSeries",
      "dataFields": {
      "value": "value",
      "category": "pot"
      },
      "ticks": {
      "disabled": true
      },
      "labels": {
      "disabled": true
      },

      }
      ],


      Can somebody see where I've gone wrong?










      share|improve this question















      I'm trying to create a pie chart with a custom set of colours using Am4Charts and the createFromConfig method.



      I've followed the tutorial here but the chart keeps appearing with it's default color set.



      Here is a sample of the JSON I've tried:



      "innerRadius": 100,
      "colors": {"list": ["#ff0000", "#00ff00", "#0000ff" ]},
      "data": {
      "0": {
      "pot": "Within 8 days",
      "value": "£111,119.70",
      },
      "1": {
      "pot": "9 - 17 days",
      "value": "£225,537.73"
      },
      "2": {
      "pot": "18+ days",
      "value": "£720,279.85"
      }
      },
      "legend": ,
      "xAxes": [
      {
      "type": "CategoryAxis",
      "title": {
      "text": "pot"
      },
      "dataFields": {
      "category": "pot",
      "title": {
      "text": "Month"
      }
      },
      "renderer": {
      "labels": {
      "rotation": 190,
      "verticalCenter": "middle",
      "horizontalCenter": "left"
      }
      }
      }
      ],

      "series": [
      {
      "type": "PieSeries",
      "dataFields": {
      "value": "value",
      "category": "pot"
      },
      "ticks": {
      "disabled": true
      },
      "labels": {
      "disabled": true
      },

      }
      ],


      Can somebody see where I've gone wrong?







      amcharts






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 19 at 19:37









      David Liang

      4,55211728




      4,55211728










      asked Nov 9 at 15:17









      Gazj354

      62




      62
























          1 Answer
          1






          active

          oldest

          votes

















          up vote
          1
          down vote













          Update 2:




          Fixed in 4.0.0-beta.85.



          Make sure you clear your browser cache after upgrading. And feel free to contact us again if you are still experiencing this issue.




          Update 1:



          Response from amchart contributor/CTO Martynas Majeris (https://github.com/martynasma):




          Looks like there are two issues: documentation is wrong and there's a bug that prevents it from working :)



          I updated the docs. It should say this:



          {
          // ...
          "series": [{
          // ...
          "colors": {
          "list": [
          "#845EC2",
          "#D65DB1",
          "#FF6F91",
          "#FF9671",
          "#FFC75F",
          "#F9F871"
          ]
          }
          }]
          }


          Also, fixed bug in dev version. New version will be released within 1-2 days.




          Original



          This might be a bug and I have opened an issue on amchart github. I will update this once I get a response: https://github.com/amcharts/amcharts4/issues/577



          By the way, I do think your configuration JSON has couple issues:





          • data is an array, not an object


          • legend is an object, not an array


          This is what I used to create the pie chart demo for the opened issue:



          // Create chart instance in one go
          let chart = am4core.createFromConfig({
          "colors": {
          "list": ["#ff0000","#00ff00", "#0000ff"]
          },
          // Create pie series
          "series": [{
          "colors": ["#ff0000","#00ff00", "#0000ff"],
          "type": "PieSeries",
          "dataFields": {
          "value": "value",
          "category": "pot"
          }
          }],
          // Add data
          "data": [{
          "pot": "Within 8 days",
          "value": "£111,119.70"
          }, {
          "pot": "9 - 17 days",
          "value": "£225,537.73"
          }, {
          "pot": "18+ days",
          "value": "£720,279.85"
          }],
          // Add legend
          "legend": {},
          "innerRadius": 100
          }, "chart", am4charts.PieChart);





          share|improve this answer























            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',
            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%2f53228462%2fcustom-colors-when-generating-a-pie-chart-from-json%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes








            up vote
            1
            down vote













            Update 2:




            Fixed in 4.0.0-beta.85.



            Make sure you clear your browser cache after upgrading. And feel free to contact us again if you are still experiencing this issue.




            Update 1:



            Response from amchart contributor/CTO Martynas Majeris (https://github.com/martynasma):




            Looks like there are two issues: documentation is wrong and there's a bug that prevents it from working :)



            I updated the docs. It should say this:



            {
            // ...
            "series": [{
            // ...
            "colors": {
            "list": [
            "#845EC2",
            "#D65DB1",
            "#FF6F91",
            "#FF9671",
            "#FFC75F",
            "#F9F871"
            ]
            }
            }]
            }


            Also, fixed bug in dev version. New version will be released within 1-2 days.




            Original



            This might be a bug and I have opened an issue on amchart github. I will update this once I get a response: https://github.com/amcharts/amcharts4/issues/577



            By the way, I do think your configuration JSON has couple issues:





            • data is an array, not an object


            • legend is an object, not an array


            This is what I used to create the pie chart demo for the opened issue:



            // Create chart instance in one go
            let chart = am4core.createFromConfig({
            "colors": {
            "list": ["#ff0000","#00ff00", "#0000ff"]
            },
            // Create pie series
            "series": [{
            "colors": ["#ff0000","#00ff00", "#0000ff"],
            "type": "PieSeries",
            "dataFields": {
            "value": "value",
            "category": "pot"
            }
            }],
            // Add data
            "data": [{
            "pot": "Within 8 days",
            "value": "£111,119.70"
            }, {
            "pot": "9 - 17 days",
            "value": "£225,537.73"
            }, {
            "pot": "18+ days",
            "value": "£720,279.85"
            }],
            // Add legend
            "legend": {},
            "innerRadius": 100
            }, "chart", am4charts.PieChart);





            share|improve this answer



























              up vote
              1
              down vote













              Update 2:




              Fixed in 4.0.0-beta.85.



              Make sure you clear your browser cache after upgrading. And feel free to contact us again if you are still experiencing this issue.




              Update 1:



              Response from amchart contributor/CTO Martynas Majeris (https://github.com/martynasma):




              Looks like there are two issues: documentation is wrong and there's a bug that prevents it from working :)



              I updated the docs. It should say this:



              {
              // ...
              "series": [{
              // ...
              "colors": {
              "list": [
              "#845EC2",
              "#D65DB1",
              "#FF6F91",
              "#FF9671",
              "#FFC75F",
              "#F9F871"
              ]
              }
              }]
              }


              Also, fixed bug in dev version. New version will be released within 1-2 days.




              Original



              This might be a bug and I have opened an issue on amchart github. I will update this once I get a response: https://github.com/amcharts/amcharts4/issues/577



              By the way, I do think your configuration JSON has couple issues:





              • data is an array, not an object


              • legend is an object, not an array


              This is what I used to create the pie chart demo for the opened issue:



              // Create chart instance in one go
              let chart = am4core.createFromConfig({
              "colors": {
              "list": ["#ff0000","#00ff00", "#0000ff"]
              },
              // Create pie series
              "series": [{
              "colors": ["#ff0000","#00ff00", "#0000ff"],
              "type": "PieSeries",
              "dataFields": {
              "value": "value",
              "category": "pot"
              }
              }],
              // Add data
              "data": [{
              "pot": "Within 8 days",
              "value": "£111,119.70"
              }, {
              "pot": "9 - 17 days",
              "value": "£225,537.73"
              }, {
              "pot": "18+ days",
              "value": "£720,279.85"
              }],
              // Add legend
              "legend": {},
              "innerRadius": 100
              }, "chart", am4charts.PieChart);





              share|improve this answer

























                up vote
                1
                down vote










                up vote
                1
                down vote









                Update 2:




                Fixed in 4.0.0-beta.85.



                Make sure you clear your browser cache after upgrading. And feel free to contact us again if you are still experiencing this issue.




                Update 1:



                Response from amchart contributor/CTO Martynas Majeris (https://github.com/martynasma):




                Looks like there are two issues: documentation is wrong and there's a bug that prevents it from working :)



                I updated the docs. It should say this:



                {
                // ...
                "series": [{
                // ...
                "colors": {
                "list": [
                "#845EC2",
                "#D65DB1",
                "#FF6F91",
                "#FF9671",
                "#FFC75F",
                "#F9F871"
                ]
                }
                }]
                }


                Also, fixed bug in dev version. New version will be released within 1-2 days.




                Original



                This might be a bug and I have opened an issue on amchart github. I will update this once I get a response: https://github.com/amcharts/amcharts4/issues/577



                By the way, I do think your configuration JSON has couple issues:





                • data is an array, not an object


                • legend is an object, not an array


                This is what I used to create the pie chart demo for the opened issue:



                // Create chart instance in one go
                let chart = am4core.createFromConfig({
                "colors": {
                "list": ["#ff0000","#00ff00", "#0000ff"]
                },
                // Create pie series
                "series": [{
                "colors": ["#ff0000","#00ff00", "#0000ff"],
                "type": "PieSeries",
                "dataFields": {
                "value": "value",
                "category": "pot"
                }
                }],
                // Add data
                "data": [{
                "pot": "Within 8 days",
                "value": "£111,119.70"
                }, {
                "pot": "9 - 17 days",
                "value": "£225,537.73"
                }, {
                "pot": "18+ days",
                "value": "£720,279.85"
                }],
                // Add legend
                "legend": {},
                "innerRadius": 100
                }, "chart", am4charts.PieChart);





                share|improve this answer














                Update 2:




                Fixed in 4.0.0-beta.85.



                Make sure you clear your browser cache after upgrading. And feel free to contact us again if you are still experiencing this issue.




                Update 1:



                Response from amchart contributor/CTO Martynas Majeris (https://github.com/martynasma):




                Looks like there are two issues: documentation is wrong and there's a bug that prevents it from working :)



                I updated the docs. It should say this:



                {
                // ...
                "series": [{
                // ...
                "colors": {
                "list": [
                "#845EC2",
                "#D65DB1",
                "#FF6F91",
                "#FF9671",
                "#FFC75F",
                "#F9F871"
                ]
                }
                }]
                }


                Also, fixed bug in dev version. New version will be released within 1-2 days.




                Original



                This might be a bug and I have opened an issue on amchart github. I will update this once I get a response: https://github.com/amcharts/amcharts4/issues/577



                By the way, I do think your configuration JSON has couple issues:





                • data is an array, not an object


                • legend is an object, not an array


                This is what I used to create the pie chart demo for the opened issue:



                // Create chart instance in one go
                let chart = am4core.createFromConfig({
                "colors": {
                "list": ["#ff0000","#00ff00", "#0000ff"]
                },
                // Create pie series
                "series": [{
                "colors": ["#ff0000","#00ff00", "#0000ff"],
                "type": "PieSeries",
                "dataFields": {
                "value": "value",
                "category": "pot"
                }
                }],
                // Add data
                "data": [{
                "pot": "Within 8 days",
                "value": "£111,119.70"
                }, {
                "pot": "9 - 17 days",
                "value": "£225,537.73"
                }, {
                "pot": "18+ days",
                "value": "£720,279.85"
                }],
                // Add legend
                "legend": {},
                "innerRadius": 100
                }, "chart", am4charts.PieChart);






                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited Nov 21 at 0:59

























                answered Nov 19 at 20:21









                David Liang

                4,55211728




                4,55211728






























                    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%2f53228462%2fcustom-colors-when-generating-a-pie-chart-from-json%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

                    Wiesbaden

                    Marschland

                    Dieringhausen