Attach chart to layout

how can i attach a chart to a cell in dhtmlxlayout and load a xml file into it?

You need to call attachChart method with chart settings:

var chartConfig = { view:"bar", .... } var chart = dhxLayout.cells("a").attachChart(chartConfig); chart.load(...);

You may find the similar sample in the chart package (for dhtmlxWindows):

dhtmlxChart/samples/08_integration/03_windows.html

whats wrong with this?:

[code]var chartConfig =({
view: “pie”,
value: “#sales#”,
details: “#year#”});

var chart = GrootLayout2.cells(“a”).attachChart(chartConfig);
chart.load(“inc/xml/sales.xml”);[/code]

The code is correct, except the “details” property - use legend instead.
I’ve attached the demo.

var chartConfig ={ view: "pie", value: "#sales#", legend: "#year#" };
charts_layout.zip (82.4 KB)

thnx its working now,

could you please also make a example for me with this 1: dhtmlxChart/samples/07_area_chart/03_stacked_area.html

(with the attach funtion)

thanks in advance!

Hi,

actually the approach is the same. Is there something unclear ?

I have simply downloaded the code and tried it in IE and Firefox and safari. The code appears to work in Firefox but not in IE. I get following error -

Webpage error details

User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C)
Timestamp: Sun, 9 Oct 2011 19:15:35 UTC

Message: Syntax error
Line: 1
Char: 1
Code: 0
URI: localhost/chart.php

Message: Could not complete the operation due to error 80020101.
Line: 7
Char: 186
Code: 0
URI: localhost/jscode/dhtmlxchart.js

Here is the code sample -
var leftchart;

	var leftchartConfig =({
  		view: "pie",
  		value: "#sales#",
  		legend: "#year#",
		pieInnerText:"#sales#"
	});
  
	leftchart = content_layout.cells('b').attachChart(leftchartConfig);
	
	leftchart.load("chart.xml");

There was another post with this error and response there was from Alexandra that she could not produce it but I get the same error in IE.
Any fixes?
Thanks.

Try to

a) load page by http, not directly from filesystem
b) be sure that page has full doctype (ie works in standard mode)
c) if issue still occurs - move initiaization code in onload handler of the page.