jQWidgets Forums

Forum Replies Created

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • in reply to: problem chart problem chart #7415

    wanfr13
    Member

    Hi dimitar

    bravo !

    jason encoding will allow me to go further
    everything is ok

    thank you very much

    in reply to: problem chart problem chart #7408

    wanfr13
    Member

    Hi Dimitar

    code html

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" lang="fr">
    <head>
    <script type="text/javascript" src="default/js/jquery.min.js"></script> //1
    <script type="text/javascript" src="default/js/jqwidgets/jqxcore.js"></script>
    <script type="text/javascript" src="default/js/jqwidgets/jqxchart.js"></script>
    <script type="text/javascript" src="default/js/jqwidgets/jqxdata.js"></script>
    <link rel="stylesheet" href="default/js/jqwidgets/styles/jqx.base.css" type="text/css" />
    <script type="text/javascript">
    $(document).ready(function() {
    var data = ‘[';
    $('.pays').each(function() {
    data = data + '{"Pays":' + $(this).text() + ',"Nb":' + $(this).next().text() + '},';
    });
    data = data.substr(0, data.length-1);
    data = data + ']‘;
    var source =
    {
    datafields: [
    { name: 'pays' },
    { name: 'nb' }
    ],
    id: 'id',
    localdata: data
    };
    var dataAdapter = new $.jqx.dataAdapter(source, {
    downloadComplete: function (data, status, xhr) { },
    loadComplete: function (data) { },
    loadError: function (xhr, status, error) { }
    });
    $('#sp7').jqxChart({
    title: "Répartitions des inscrits par pays",
    enableAnimations: true,
    padding: { left: 20, top: 5, right: 20, bottom: 5 },
    legendLayout: { left: 20, top: 155, width: 200, height: 200, flow: 'vertical' },
    titlePadding: { left: 90, top: 0, right: 90, bottom: 10 },
    source: dataAdapter,
    colorScheme: 'scheme03',
    seriesGroups: [{
    type: 'pie',
    showLabels: true,
    series: [{
    dataField: 'nb',
    displayText: 'pays',
    labelRadius: 120,
    initialAngle: 15,
    radius: 95,
    centerOffset: 0
    }]
    }]
    });
    });
    </script>
    </head>
    <body>
    <div id="ssite">
    <p class="hidden">
    <span class="pays">non-renseigné</span><span class="nb">70</span>
    <span class="pays">Belgique</span><span class="nb">2</span>
    <span class="pays">France</span><span class="nb">25</span>
    <span class="pays">suisse</span><span class="nb">1</span>
    <span class="pays">USA</span><span class="nb">1</span>
    </p>
    <div id="sp7" style="height: 400px; position: relative; left: 0px; top: 0px;"></div>
    </div>
    </body>
    </html>

    code php

    $r_usr = pg_query ("SELECT usr_pays, COUNT(usr_pays) FROM lt_usr GROUP BY usr_pays ORDER BY usr_pays ASC;");
    if (!$r_usr) {
    echo "Erreur durant la requète sur lt_eur.<BR>";
    exit;
    }
    $num_usr = pg_num_rows($r_usr);
    echo "\n\t\t\t\t\t\t\t" .'<div id="ssite">'
    ."\n\t\t\t\t\t\t\t\t" ."<h3>Statistiques de l'espace privé</h3>"
    ."\n\t\t\t\t\t\t\t\t" .'<p class="hidden">';
    while ($arr_usr = pg_fetch_array($r_usr)) {
    if ($arr_usr['usr_pays'] ==='') {
    $arr_usr['usr_pays'] = 'non-renseigné';
    }
    echo "\n\t\t\t\t\t\t\t\t\t" .'<span class="pays">' .$arr_usr['usr_pays'] .'</span><span class="nb">' .$arr_usr['count'] .'</span>';
    }
    echo "\n\t\t\t\t\t\t\t\t\t" .'</p>';
    echo "\n\t\t\t\t\t\t\t\t" .'<div id="sp7" style="height: 400px; position: relative; left: 0px; top: 0px;"></div>';
    echo "\n\t\t\t\t\t\t\t" .'</div>'
    ."\n\t\t\t\t\t\t";

    excuse me for my ignorance
    thank you very much
    wanfr

    in reply to: problem chart problem chart #7389

    wanfr13
    Member

    Hi Dimitar,

    Here is my code


    echo 'p class=hidden;

    $r_usr = pg_query ("SELECT usr_pays, COUNT(usr_pays) FROM lt_usr GROUP BY usr_pays ORDER BY usr_pays ASC;");
    while ($arr_usr = pg_fetch_array($r_usr)) {
    if ($arr_usr['usr_pays'] ==='') {
    $arr_usr['usr_pays'] = 'non-renseigné';
    }
    echo 'span class=pays' .$arr_usr['usr_pays'] .'/span span class=nb' .$arr_usr['count'] .'/span';
    }

    echo 'p div style=width: 680px;height: 400px /div'

    var data = '[';

    $('.pays').each(function() {
    data = data + '{"Pays":' + $(this).text() + ',"Nb":' + $(this).next().text() + '},';
    });

    data = data.substr(0, data.length-1);
    data = data + ']';

    $(this).text () is the first span is the name of the country ( USA, France Belgique……)
    $(this).next ().text () the second span is the number of membre (1, 25, 2……)

    Best regards

    in reply to: problem chart problem chart #7374

    wanfr13
    Member

    hello Dimitar,

    ok and thank you for :

    var source = {
    datafields: [
    { name: ‘pays’ },
    { name: ‘nb’ }
    ],
    id: ‘id’,
    localdata: data
    };

    var dataAdapter = new $.jqx.dataAdapter(source, {
    downloadComplete: function (data, status, xhr) { },
    loadComplete: function (data) { },
    loadError: function (xhr, status, error) { }
    });
    var dataAdapter = new $.jqx.dataAdapter(source, {
    downloadComplete: function (data, status, xhr) { },
    loadComplete: function (data) { },
    loadError: function (xhr, status, error) { }
    });

    works with :
    var data1 = [{ pays: “USA”, nb: 1 }, { pays: “France”, nb: 25 }, { pays: “belgique”, nb: 2}];

    but not work with :

    var data = '[';
    $('.pays').each(function() {
    data = data + '{"Pays":' + $(this).text() + ',"Nb":' + $(this).next().text() + '},';
    });
    data = data.substr(0, data.length-1);
    data = data + ']';

    alert(data);
    result : [{ pays: “USA”, nb: 1 }, { pays: “France”, nb: 25 }, { pays: “belgique”, nb: 2}]

    I do not understand the difference…

    Thanks

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