1. #1
    Sencha User
    Join Date
    Nov 2011
    Posts
    8
    Vote Rating
    0
    sreenath886 is on a distinguished road

      0  

    Lightbulb extjs 4 piechart +mysqldatabase connection

    extjs 4 piechart +mysqldatabase connection


    am new sencha user .am trying to connect extjs 4 piechart with mysql but its not cannecting.wher i want to chainge in my extjs code?plzz help me.
    ------------------------------------------------------------------------------------------------------------------------
    my extjs code
    ---------------------------------------------------------


    Ext.require('Ext.chart.*');
    Ext.require('Ext.layout.container.Fit');

    Ext.onReady(function(){

    var myStore = new Ext.data.Store({
    proxy: new Ext.data.HttpProxy({
    url: 'data.php',
    method: 'POST'
    }),
    baseParams:{task: "show"},

    reader: new Ext.data.JsonReader(
    {
    //root: 'results',
    id: 'id',
    //totalProperty: 'total'
    },
    [
    {name: 'mark'},
    {name: 'subject'}
    ]
    ),
    }
    );
    myStore.load();



    var donut = false,
    panel1 = Ext.create('widget.panel', {
    width: 800,
    height: 600,
    title: 'Sreenath',
    renderTo: Ext.getBody(),
    layout: 'fit',



    items: {
    xtype: 'chart',
    id: 'chartCmp',
    animate: true,
    store: myStore,
    dataField: 'mark',
    categoryField: 'subject',
    shadow: true,
    legend: {
    position: 'right'
    },








    /*insetPadding: 60,
    theme: 'Base:gradients',
    series: [{
    type: 'pie',
    field: 'mark',
    showInLegend: true,
    donut: donut,
    tips: {
    trackMouse: true,
    width: 140,
    height: 28,


    renderer: function(storeItem, item) {
    //calculate percentage.
    var total = 0;
    myStore.each(function(rec) {
    total += rec.get('mark');
    });
    this.setTitle(storeItem.get('subject') + ': ' + Math.round(storeItem.get('mark') / total * 100) + '%');
    }
    },*/
    highlight: {
    segment: {
    margin: 20
    }
    },
    label: {
    field: 'subject',
    display: 'rotate',
    contrast: true,
    font: '18px Arial'
    }


    }
    });
    });

    --------------------------------------------------------------------------------------------------
    my php code
    ---------------------------------------------------------------------------------------------------
    <?php

    $db_name="admin";
    $tbl_name="piechart";
    $conn = mysql_connect("localhost", "root", "") or die (mysql_error ());
    $db = mysql_select_db ("$db_name") or die (mysql_error ());

    $result=mysql_query ("SELECT * FROM piechart") or die (mysql_error ());

    $data = array();

    while ($row=mysql_fetch_object($result))
    {
    $data [] = $row;
    }

    echo json_encode($data);
    ?>

    ---------------------------------------------------------
    its urgent please help me.

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,347
    Vote Rating
    846
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    Are you using Ext JS 3 and 4 on the same page? Wouldn't do that if you can help it.

    Are you seeing any data being returned from your PHP to your app?
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

  3. #3
    Sencha User
    Join Date
    Nov 2011
    Posts
    8
    Vote Rating
    0
    sreenath886 is on a distinguished road

      0  

    Default


    thak you for your quick responce .ya data is returned from my PHP to my app.but its not displaying.can you give sample extjs4 pie chart extjs script .hope you will help me.

  4. #4
    Sencha User
    Join Date
    Jun 2012
    Posts
    80
    Vote Rating
    0
    mohaskuar is on a distinguished road

      0  

    Default TOO late

    TOO late


    i knw its too late to answer this question which maght not be helpfull for the one who actually started it.....i hope it will for another person which have similiar problem ....the problem is while using store....you use data store while returning a json decoded data from php file file.....so you have to try using Ext.data.jsonStore or you have to return your data from php with out decoding to json, ...............

Thread Participants: 2

Tags for this Thread