jQuery UI Widgets Forums Chart Pie Chart using PHP

Tagged: , ,

This topic contains 1 reply, has 2 voices, and was last updated by  Peter Stoev 12 years, 8 months ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
  • Pie Chart using PHP #6157

    petite_moi
    Member

    I am trying to create a pie chart using data source from a php.

    data.php (this is working)
    $test_array = array
    (
    “passed”=>$data[‘test’][‘percent_passed’],
    “failed”=>$data[‘test’][‘percent_failed’],
    “error”=>$data[‘test’][‘percent_error’]
    );

    echo json_encode($test_array);

    Here is the javascript code:

    $(document).ready(function () {
    var source =
    {
    datatype: “json”,
    datafields: [
    { name: ‘passed’},
    { name: ‘failed’},
    { name: ‘error’}
    ],
    url: ‘DataSource/data.php’
    };

    var dataAdapter = new $.jqx.dataAdapter(source,
    {
    autoBind: true,
    async: false,
    downloadComplete: function () { },
    loadComplete: function () { },
    loadError: function () { }
    });

    var settings = {
    title: “Test Result”,
    description: “”,
    enableAnimations: true,
    showLegend: true,
    legendLayout: { left: 500, top: 140, width: 300, height: 200, flow: ‘vertical’ },
    padding: { left: 5, top: 5, right: 5, bottom: 5 },
    titlePadding: { left: 0, top: 0, right: 0, bottom: 10 },
    source: dataAdapter,
    colorScheme: ‘scheme03’,
    seriesGroups:
    [
    {
    type: ‘pie’,
    showLabels: true,
    series:
    [
    {
    dataField: ‘passed’,
    displayText: ‘Passed’,
    labelRadius: 120,
    initialAngle: 15,
    radius: 95,
    centerOffset: 0,
    formatSettings: { sufix: ‘%’, decimalPlaces: 1 }
    }
    {
    dataField: ‘failed’,
    displayText: ‘Failed’,
    labelRadius: 120,
    initialAngle: 15,
    radius: 95,
    centerOffset: 0,
    formatSettings: { sufix: ‘%’, decimalPlaces: 1 }
    }
    {
    dataField: ‘error’,
    displayText: ‘Error’,
    labelRadius: 120,
    initialAngle: 15,
    radius: 95,
    centerOffset: 0,
    formatSettings: { sufix: ‘%’, decimalPlaces: 1 }
    }
    ]
    }
    ]
    };

    // setup the chart
    $(‘#jqxpieChart’).jqxChart(settings);
    });

    Pie Chart using PHP #6193

    Peter Stoev
    Keymaster

    Hi petite_moi,

    For using the jqxChart with PHP, I suggest you to take a look at this help topic: php-server-side-chart-binding.htm.

    Best Wishes,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.