Uncaught TypeError: d3plus.P ie не является конструктором - PullRequest
1 голос
/ 29 мая 2020

Я хочу сделать диаграмму P ie на основе библиотеки d3plus. Я пытаюсь использовать приведенный ниже код (но у меня проблема, d3plus.P ie не является конструктором )

<html>
    <head>
        <title>D3Plus</title>
        <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/d3plus/1.9.8/d3plus.full.js"></script>
    </head>
    <body>


        <script>
            var myData = [
              {"Group": "Store", "Sub-Group": "Convenience Store", "Number of Food Stores": 100},
              {"Group": "Store", "Sub-Group": "Grocery Store", "Number of Food Stores": 150},
              {"Group": "Store", "Sub-Group": "Farmer's Market", "Number of Food Stores": 50},
              {"Group": "Store", "Sub-Group": "Supercenters", "Number of Food Stores": 30},
              {"Group": "Restaurant", "Sub-Group": "Fast-Food Restaurant", "Number of Food Stores": 60},
              {"Group": "Restaurant", "Sub-Group": "Full-Service Restaurant", "Number of Food Stores": 120}
            ];

            new d3plus.Pie()
              .config({
                data: myData,
                groupBy: ["Group", "Sub-Group"],
                value: function(d) {
                  return d["Number of Food Stores"];
                }
              })
              .render();
        </script>
    </body>
</html>

1 Ответ

1 голос
/ 30 мая 2020

Похоже, вам нужен другой источник, включая иерархию

https://d3plus.org/js/d3plus-hierarchy.v0.8.full.min.js"

<html>
    <head>
        <title>D3Plus</title>
  
        <script type="text/javascript" src="https://d3plus.org/js/d3plus-hierarchy.v0.8.full.min.js"></script>
    </head>
    <body>


        <script>
            var myData = [
              {"Group": "Store", "Sub-Group": "Convenience Store", "Number of Food Stores": 100},
              {"Group": "Store", "Sub-Group": "Grocery Store", "Number of Food Stores": 150},
              {"Group": "Store", "Sub-Group": "Farmer's Market", "Number of Food Stores": 50},
              {"Group": "Store", "Sub-Group": "Supercenters", "Number of Food Stores": 30},
              {"Group": "Restaurant", "Sub-Group": "Fast-Food Restaurant", "Number of Food Stores": 60},
              {"Group": "Restaurant", "Sub-Group": "Full-Service Restaurant", "Number of Food Stores": 120}
            ];
            new d3plus.Pie()
              .config({
                data: myData,
                groupBy: ["Group", "Sub-Group"],
                value: function(d) {
                  return d["Number of Food Stores"];
                }
              })
              .render();
        </script>
    </body>
</html>

Список модулей d3plus можно найти по адресу https://github.com/d3plus

...