Function chart.load("some.xml", "xml");

Hi,
I want to create a basical pie chart with this XMLfile:


31
#80ff7a
1


11
#bdff33
2


Can someone explain me how can I use the chart.load(“some.xml”, “xml”) function in the script?
I cannot obtain a result with that function while I do with that instead of the function:
var data = [
{ count:“31”, result:“1” ,color:“#80ff7a”},
{ count:“11”, result:“2” ,color:“#bdff33”},
{ count:“7”, result:“3” ,color:“#ff9e2a”},
{ count:“9”, result:“4” ,color:“#ff561b”},
{ count:“7”, result:“5” ,color:“#ff71be”},
{ count:“6”, result:“6” ,color:“#ffea69”}
];

Thx

The working script:

Pie Chart

Pie Chart

And the no-working script:

Pie Chart

Pie Chart

Hi
So, there is some things you have missed:

  1. pieChart.load(“Running.xml”, “xml”); must be loaded AFTER the window is loaded
  2. You can’t use pieChart.parse(data,“xml”); if you haven’t define it. If you have xml - you must load your chart structure from this file.

[code]

Pie Chart

Pie Chart

[/code]

If you have XML data, you need to use load() method:
dhtmlx.com/docs/products/dht … d_xml.html
If you have JSON data, you need to use parse() method:
dhtmlx.com/docs/products/dht … _json.html
With with the relevant data structure
About XML you know (you have posted xml structure in the 1th message).
And JSON need to be placed before chart init or you can load it from json file using the name of the object.

Read more about it here:
docs.dhtmlx.com/doku.php?id=dhtmlxchart:dhxinit
docs.dhtmlx.com/doku.php?id=dhtmlxchart:dhxdata

My hero. Thx man!

You are welcome!

Hello everyone!

I did download DHTMLXSuite_v403_std. I have “dhtmlxchart.js” at “\dhtmlxSuite_v403_std\sources\dhtmlxChart\codebase” but i don’t find “dhtmlxchart.css” anywhere in the package.

Hello, Stealthbits
dhtmlxChart doesn’t have such file to be built, because our charts use CANVAS

Thanks for your quick reply.
In your example, you have a line

. That is why I was looking for dhtmlxchart.css file. And also I did copy your code and made xml file but did not get it working. IE just shows title "pie chart" and blank square box. i kept html and xml files under "\dhtmlxSuite_v403_std\sources\dhtmlxChart".

Script:

Pie Chart

Pie Chart

------------------------------------------------------------------------------------ [u]XML data:[/u] ------------------------------------------------------------------------------------ 31 #80ff7a 1 11 #bdff33 2 ---------------------------------------------------------------------------------------------

And also I noticed that, sample code uses

which are different than your javascreept and css.

It seems like you have mixed 3.6 and 4.0.3 version… Could you provide us completed demo to inspect the issue?
docs.dhtmlx.com/auxiliary_docs__ … pport.html
Now we use (and recommend) compilled dhtmlx.js and dhtmlx.css files

I am using IE11 and trying to load 01_load-xml.html from sample. Attached is the screenshot of the IE debugger.It says “Access Denied”.

args:
this.post = false
j = …/common/data.xml
this._sync = undefined


You need to check domains of loaded page and page which send requests. They must be the same

Sample code and sample data both are same machine and I am trying to load html page on same machine too.

In this case we need completed demo from you or a direct link to you project to inspect the issue
docs.dhtmlx.com/auxiliary_docs__ … pport.html

Hey Darya, I got it working now. I think i had some issue with my IIS and re-install IIS works fine.

Thanks for you time!

Ok :slight_smile:
You are wlecome!

Hey Darya,

One more question regarding loading data from xml file. I am trying to load “dhtmlxSuite_v403_std\samples\dhtmlxChart\01_initialization\01_load_xml.html”.I got it working if i access through IIS but its not working when i load html in web browser. I am getting following error:

XMLHttpRequest cannot load file:///C:/Users/stealthbits/Desktop/dhtmlxSuite_v403_std/samples/dhtmlxChart/common/data.xml. Cross origin requests are only supported for HTTP. /C:/Users/stealthbits/Desktop/dhtmlxSuite_v403_std/samples/dhtmlxChart/01_initialization/01_load_xml.html:1
Uncaught NetworkError: Failed to execute ‘send’ on ‘XMLHttpRequest’: Failed to load ‘file:///C:/Users/stealthbits/Desktop/dhtmlxSuite_v403_std/samples/dhtmlxChart/common/data.xml’. /C:/Users/stealthbits/Desktop/dhtmlxSuite_v403_std/codebase/dhtmlx.js:9
Attaching.

Attached is demo project.

Why i am asking this question because Our application creates reports and it publish on IIS and it opens html file in web browser too. Currently we are using flash for charting but we would like to upgrade it to DHTMLX 4.0.
Load_XML.zip (297 KB)

There is the answer to your question :wink:
You need to load ALL our samples “under” any local server

Yeah, everything(sample and data) on same local server and Also i am trying to load html file on same machine.

It is not localserver path… It must be something like:
localhost/dhtmlxSuite_v403_std/samples/dhtmlxChart/common/data.xml