Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8835283
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T09:13:29+00:00 2026-06-14T09:13:29+00:00

I have some problem with pie charts on ExtJS 4.1. I load by Ajax

  • 0

I have some problem with pie charts on ExtJS 4.1.

I load by Ajax and Json the datastore:

Ext.define('MyModel', {
    extend: 'Ext.data.Model',
    fields: ['status', 'data', 'data1', 'data2']
});

var store1 = Ext.create('Ext.data.JsonStore', {
    model: 'MyModel',
    proxy: {
        type: 'ajax',
        url : 'PieChartJsonServlet',
    },
    autoLoad: true
});

I would like to display pie charts representing:
1) data by status
2) data1 by status
3) data2 by status

To display each pie chart, I click on buttons from tbar on a panel.

When I load HTML page, the first chart (data by status) is correctly loaded and display.

My problem is after clicking on buttons from tbar, data seem to be loaded but pie chart doesn’t refresh! (When I highlight slices, I display loaded data and I see data are well loaded)

My code:

Ext.require('Ext.chart.*');
Ext.require(['Ext.layout.container.Fit', 'Ext.window.MessageBox']);
Ext.require('Ext.JSON.*');

Ext.onReady(function () {
Ext.define('MyModel', {
    extend: 'Ext.data.Model',
    fields: ['status', 'data', 'data1', 'data2']
});

var store1 = Ext.create('Ext.data.JsonStore', {
    model: 'MyModel',
    proxy: {
        type: 'ajax',
        url : 'PieChartJsonServlet',
    },
    autoLoad: true
});

var titlePieChart = 'Data by status',
dataToDisplay = 'data',
highlightToDisplay = ' data',
chart = Ext.create('Ext.chart.Chart', {
    xtype: 'chart',
    animate: true,
    store: store1,
    shadow: true,
    legend: {
        position: 'right'
    },
    insetPadding: 60,
    theme: 'Base:gradients',
    items: [{
        type  : 'text',
        text  : titlePieChart,
        font  : '18px Arial',
        width : 100,
        height: 30,
        x : 155,
        y : 30
     }],
     series: [{
        type: 'pie',
        field: dataToDisplay,
        showInLegend: true,
        tips: {
          trackMouse: true,
          width: 180,
          height: 35,
          renderer: function(storeItem, item) {
              var total = 0;
              store1.each(function(rec) {
                  total += rec.get(dataToDisplay);
              });
              this.setTitle(storeItem.get('status') + ' : ' + storeItem.get(dataToDisplay) + highlightToDisplay + '\n(' + Math.round(storeItem.get(dataToDisplay) / total * 100) + '%)');
          }
        },
        highlight: {
          segment: {
            margin: 20
          }
        },
        label: {
            field: 'status',
            display: 'rotate',
            font: '18px Arial',
        }
    }]
});

var panel1 = Ext.create('widget.panel', {
    width: 600,
    height: 500,
    renderTo: 'chartCmp',
    layout: 'fit',
    tbar: [{
        text: 'Data',
            handler: function(button, evt) {
            titlePieChart = 'Data by status',
            dataToDisplay = 'data';
            highlightToDisplay = ' data',
            chart.refresh(); // Doesnt' work !
        }
    }, {
        text: 'Data 1',
        handler: function(button, evt) {
            titlePieChart = 'Data1 by status',
            dataToDisplay = 'data1';
            highlightToDisplay = ' data1',
            chart.refresh(); // Doesnt' work !
        }
    }, {
        text: 'Data 2',
        handler: function(button, evt) {
            titlePieChart = 'Data2 by status',
            dataToDisplay = 'data2';
            highlightToDisplay = ' data2',
            chart.refresh(); // Doesnt' work !
        }
    }],
    items: chart
});
});

Each line “chart.refresh();” from tbar doesn’t work whereas I would like a refreshed chart.

For information, I use ExtJS 4.1 on java web application.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T09:13:30+00:00Added an answer on June 14, 2026 at 9:13 am

    With these lines of code for tbar, it works :

    tbar: [{
        text: 'Data',
            handler: function(button, evt) {
            titlePieChart = 'Data by status',
            dataToDisplay = 'data';
            chart.series.first().field = dataToDisplay,
            highlightToDisplay = ' data',
            chart.refresh();
        }
    }, {
        text: 'Data 1',
        handler: function(button, evt) {
            titlePieChart = 'Data1 by status',
            dataToDisplay = 'data1';
            chart.series.first().field = dataToDisplay,
            highlightToDisplay = ' data1',
            chart.refresh();
        }
    }, {
        text: 'Data 2',
        handler: function(button, evt) {
            titlePieChart = 'Data2 by status',
            dataToDisplay = 'data2';
            chart.series.first().field = dataToDisplay,
            highlightToDisplay = ' data2',
            chart.refresh();
        }
    }],
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some problem to get the utf-8 string from PHP using jQuery $.load()
I have some problem. Consider this data schema in DB (for simplicity I omit
I have some pretty basic data for a pie chart. Yes: 189.84 (57.03%) No:
In a ajax-driven site I have added some default data using the ajaxSetup, ala
I have some problem with the cursor when using JOprionPane. I set a cursor
I have some problem. Dialog.dismiss() does not work. I want to input ip, username,
I have some problem with this mongoid. It's my first time to use mongoDB,
I have some problem with MySQL Workbench in that I sometimes can't set foreign
I have some problem in my JDBC code. I am trying to connect through
I have some problem with Emit mapper when I try to save in database

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.