DHTMLX Charts

Hello,
I seem to have a problem generating more than one chart (using php) in a layout Tab.

I get …

Webpage error details

User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729)
Timestamp: Thu, 1 Jul 2010 14:43:04 UTC

Message: Invalid argument.
Line: 82
Char: 220
Code: 0
URI: localhost/dhtml/dhtmlxchart.js

… when trying to load more than one chart in the layout (dhtmlx Tab).
The first chart does not render properly, the second chart does. ???
Please let me know what I else I can supply to help in this issue.
Thank you.
Rob.

Hello,

could you please provide the example of initialization to reproduce the problem locally ?

Hello,
Here is the first php file that produces the bar/pie chart.
The second file is almost identical except for the database logic
Each file renders separately but only the last one if I try both files.
I use: formtab.cells(tab_name).attachURL(file_name.php)
to render each php file.

//////////////////////////////////////////////////////////////
// db connection parameters
require_once(“config.php”);
$res = mysql_connect($mysql_server,$mysql_user,$mysql_pass) or die(mysql_error());
mysql_select_db($mysql_db,$res) or die(mysql_error());

$database = $mysql_db;
$table = “training”;
$year = “2009”;
$sql = "SELECT
training.instr as instructor,
count(training.cdate) as courses
FROM training
where training.cdate like ‘{$year}%’
group by instructor
order by instructor LIMIT 0, 200 ";

//start output of data

$res = mysql_query($sql);

// send_xml($res); // this creates and sends out the xml stream
create_xml($res); // this creates a file ‘course.xml’ for use in html down below

function send_xml($res){
$seq = 0;
$str = ‘’;

//include XML Header (as response will be in xml format)
header(“Content-type: text/xml”);
//encoding may be different in your case
echo(’<?xml version="1.0" encoding="utf-8"?>’);

if ($res){
print (’’);

while($row=mysql_fetch_array($res)){
	// loop through sql query rows
	$course	= $row['instructor'];
	$courses	= $row['courses'];
	
	//create xml tag for chart
	$seq++;
	print ('<item id="'.$seq.'">');
	print ('<course>'.$course.'</course>');
	print ('<qty>'.$courses.'</qty>');
	print ('</item>');
	}
	print ('</data>');
}

}

function create_xml($res){
$seq = 0;
$str = ‘’;

if ($res){
	$str = $str.'<data>';

while($row=mysql_fetch_array($res)){
	// loop through sql query rows
	$course	= $row['instructor'];
	$courses	= $row['courses'];
	
	//create xml tag for chart
	$seq++;
	$str = $str.'<item id="'.$seq.'">';
	$str = $str.'<course>'.$course.'</course>';
	$str = $str.'<qty>'.$courses.'</qty>';
	$str = $str.'</item>';
	}
	$str = $str.'</data>';

file_put_contents("chart2.xml",$str);

}

}
?>

CWST Instructor Analysis
<style>
	.dhx_chart_title{
		padding-left:3px
	}
</style>

Instructor History Analysis times (<?php echo $year ?>)

var instructor_barChart =  new dhtmlXChart({
	view:"bar",
	container:"instructor_bar_chart_container",
    value:"#qty#",
	label:"#course#",
	width:30,
	tooltip: "#course#",
	xAxis:{
		title:"Instructor History Analysis times (<?php echo $year ?>)",
		template:"#qty#"
	},
	yAxis:{
                    start:0,
                    end:  600,
                    step: 50,
                    template:"{obj}",
		title:""
}
});

function filter_qty(){ instructor_barChart.filter(function(obj){ return obj.qty >= 5 });

}

var instructor_pieChart =  new dhtmlXChart({
	view:"pie", // pie3D
	container:"instructor_pie_chart_container",
    	value:"#qty#",
	label:"#course#",
	tooltip: "#course#",
	gradient: true
	
});

instructor_barChart.load("chart2.xml",filter_qty); // display a barchart
instructor_pieChart.load("chart2.xml",filter_qty); // display the same in piechart

</script>
////////////////////////////////////////////////////////////////////////////////

I use: formtab.cells(tab_name).attachURL(file_name.php);
to render each php file.

I hope I am clear.
Thx