PieChart does not load (legend does load)

Hi all,

I cant seem to get the pie-chart to work. I try to load the values for the piechart from a php page, which contains a mysql query which returns two values (id, environment (dev,dev2,etc). I set up the chart as following:

[code]var main_layout = new dhtmlXLayoutObject(document.body, ‘1C’);

var a = main_layout.cells('a');
var chart_1 = a.attachChart({
	view: 'pie3D' ,
    legend:{"marker":{"type":"round","width":15},
            "values":[{"text":"Dev","color":"#3399ff"},
                     {"text":"Dev2","color":"#66cc00", "markerType":"item"}]},
            
	gradient: false,

});

chart_1.load("../data/DLconnector.php", "xml");[/code]

For some reason i only see the ‘legend’. The piechart itself is not loaded. Am i missing something? I did include the codebase/dhtmlx.js file.

Thanks in advance.

Regards,
Bakk

Hi,

could you attach an example of generated xml ? Have you checked whether DLconnector.php generated correct xml ?

Hi Alexandra,

See the attached file for the XML (7zip file).
The output seems legit to me. I use the following code in the DLconnector.php file:

[code]<?php
require_once(dirname(FILE) . ‘/…/conf/config.php’);
$res=mysql_connect($mysql_server,$mysql_user,$mysql_pass);
mysql_select_db($mysql_db);

require(“…/lib/dhtmlx/connector/grid_connector.php”);
$grid = new GridConnector($res);

$grid->dynamic_loading(100);
$grid->render_table(“dynamic_login”,“id”,“id,omgeving”);
?>[/code]

Thanks for your assistance.
dlconnector.php.xml.7z (268 Bytes)

Hi,

there are several issues:

you are using GridConnector that generates xml in grid format that doesn’t fit Chart. Please use DataViewConnector instead:

require("…/lib/dhtmlx/connector/dataview_connector.php");
$data = new DataViewConnector($res);
$data->dynamic_loading(100);
$data->render_table(“dynamic_login”,“id”,“omgeving”);

  1. also you should define “value” template in chart configuration as “#value#” is default and you are loading items with “omgeving” property:

var chart_1 = a.attachChart({
value: “#omgeving#”,

I tried your suggestions, but did not manage to get it working yet.

I took the following actions:

  • Altered the DLconnector.php to your suggestions. The code looks like:

[code]<?php
$res=mysql_connect($mysql_server,$mysql_user,$mysql_pass);
mysql_select_db($mysql_db);

require(“…/lib/dhtmlx/connector/dataview_connector.php”);
$data = new DataViewConnector($res);

$data->dynamic_loading(100);
$data->render_table(“dynamic_login”,“id”,“omgeving”);
?>[/code]

The output from the file is in the attachment.

  • Altered the chart code to:

[code]function buildInterface()
{

var main_layout = new dhtmlXLayoutObject(document.body, '1C');

var a = main_layout.cells('a');	
var chart_1 = a.attachChart({
    value: "#omgeving#",
    view: "pie3D",
    legend:{"marker":{"type":"round","width":15},
            "values":[{"text":"Dev","color":"#3399ff"},
                     {"text":"Dev2","color":"#66cc00", "markerType":"item"}]},
	gradient: false

});

chart_1.load("../data/dlconnector.php", "xml");
}

dhtmlxEvent(window,"load", buildInterface);[/code]

In chrome the Legenda loads up. In IE(8) the following error is shown after loading up the (empty) page (grid ‘a’ is shown, but there is not showing any values/chars):

Bericht: Kan deze bewerking niet voltooien door fout 80020101. Regel: 3097 Teken: 73 Code: 0 URI: [...]/codebase/dhtmlx.js

Thank you for all your support so far.
dlconnector2.7z (258 Bytes)

Chart represents number values. And you return string.

Please see chart samples and docs for more details.