AnsweredAssumed Answered

Uncaught TypeError: chart.addPlot is not a function

Question asked by jbridwell_Dewberry on Aug 9, 2018
Latest reply on Aug 9, 2018 by jbridwell_Dewberry

I recently posted a question about adding a pie chart to the results of Robert's eSearch widget and I believe I have found a simple way to do that using Dojo. However, I keep getting an error - Uncaught TypeError: chart.addPlot is not a function. I am pretty sure this is a problem with the way I have set up my dependencies under define([...], function()..., but I don't see it. I have my dependencies set up like this:

define(['dojo/_base/declare','dijit/_WidgetsInTemplateMixin',   'dojo/io-query','dojo/query','dijit/MenuItem', ....//Dependencies added for Pie Chart. See corresponding functions'dojox/charting/Chart2D', 'dojox/charting/plot2d/Pie','dojox/charting/action2d/Highlight',   'dojox/charting/action2d/MoveSlice', 'dojox/charting/action2d/Tooltip','dojox/charting/themes/PrimaryColors'], function (declare, _WidgetsInTemplateMixin, BaseWidget, ... ...Chart2D, Pie, Highlight, MoveSlice, Tooltip, dojoxTheme) { /*jshint unused: true*/return declare([BaseWidget, _WidgetsInTemplateMixin], { ...

As you can see my functions are in the same order: Chart2D, Pie, Highlight, MoveSlice, Tooltip, dojoxTheme. Further down in the code, I create a variable called chart by calling the constructor new Chart2D. I assumed that I would then be able to use any methods under it. .addPlot is a method of Chart2D.

var c = domConstruct.create("div", {      id: "Chart"    }, domConstruct.create("div"));  var chart = new Chart2D(c);

However when I try to use the following, I get the error thrown. Is there something I am missing back when I added my dependencies? Suggestions?

chart.addPlot("default", {      type: "Pie",      radius: 50,      htmlLabels: true    });

Outcomes