Search code examples
dojotooltipdojox.charting

creating dojox chart with tooltip returns error: TypeError: invalid 'in' operand source


Dojo version: 1.10.4 downloaded 11/24/2015 When I create a new Tooltip, there is an error returned: TypeError: invalid 'in' operand source thrown from dojox/lang/utils.js line 46 if(x in source && !(x in empty)){...} where source is the text, "default", but it is expecting an object. The text, "default" appears to be from the call to create the Tooltip, indicated in the code below. (I've removed code that I think is unnecessary to understand the problem.)

require([ "dojox/charting/Chart", "dojox/charting/widget/Legend", 
"dojox/charting/axis2d/Default", "dojox/charting/action2d/Tooltip", 
"dojox/charting/plot2d/Bars", "dojox/charting/plot2d/ClusteredBars", 
"dojox/charting/plot2d/StackedBars", "dojo/domReady!"], 
function(Chart, Legend, Tooltip){

var barChart = new Chart("WPDDashboard_DojoBarChart3_1",
{ title: 'Finance Comparison', titleFont: 'bold 100% Arial});

barChart.addPlot("default", {
type: 'ClusteredBars' , gap: 5, stroke: {
color: 'black', width: 2}, fill: '#3366cc', shadow: {
dx: 2, dy: 2}});

barChart.connectToPlot("default" ........);

barChart.addAxis(.......);

//I think this is the offending line
var tip = new Tooltip(barChart, "default");

barChart.render();
});

Solution

  • Your ordering of the required objects doesn't line up with the declaration. You're requiring Chart, Legend, Default, and then Tooltip while you're declaring Chart, Legend, and then Tooltip. So what you've done is you named the Default chart to Tooltip and tried using it. Try fixing the order and that should work.