1. #1
    Sencha User
    Join Date
    Sep 2010
    Posts
    9
    Vote Rating
    0
    VedvratSharma is on a distinguished road

      0  

    Default Unanswered: ExtJS Bar Chart x-axis to be distributed uniformly.

    Unanswered: ExtJS Bar Chart x-axis to be distributed uniformly.


    Hi,

    Context:
    I am using a ExtJS Bar chart for my project. The ExtJS version is 4.1.1a.

    Problem:
    The x-axis chart numbering should be proper.

    Not Uniform.png
    In the above chart, 0(Zero) - spans to 2 columns. 1 - spans 5 columns, 2 - spans 4 columns
    Ideally, there needs to be only one column span for 0, 1 & 2.

    The chart works fine if the values are increased above 2
    uniform.png
    ISSUE : The chart needs to behave/distribute uniformly across all the scenarios.

    Code:
    Have attached the Code used for the same:
    Code:
    Ext.chart.theme.White = Ext.extend(Ext.chart.theme.Base, {
                constructor: function() {
                   Ext.chart.theme.White.superclass.constructor.call(this, {
                       axis: {
                           stroke: 'rgb(8,69,148)',
                           'stroke-width': 1
                       },
                       axisLabel: {
                           fill: 'rgb(8,69,148)',
                           font: '12px Lucida Grande',
                           'font-family': 'Arial, Helvetica, sans-serif',
                           spacing: 2,
                           padding: 5,
                           renderer: function(v) { return v; }
                       },
                       axisTitle: {
                          font: 'bold 18px Lucida Grande'
                       }
                   });
                }
        });
    
        var colors = ['rgb(158, 195, 222)'];
        Ext.chart.theme.Browser = Ext.extend(Ext.chart.theme.Base, {
            constructor: function(config) {
                Ext.chart.theme.Base.prototype.constructor.call(this, Ext.apply({
                    colors: colors
                }, config));
            }
        });
    
    barChart = Ext.create('Ext.chart.Chart',{
            renderTo: 'contentTab10',
            id: 'chartCmp',
            xtype: 'chart',
            width: 400,
            height: 110,
            animate: true,
            store: storeIDMgmt,
            theme: 'Browser:gradients',
            style:{            
                marginLeft: '25px',
                marginTop: '-7px'
            },
            axes: [{
                type: 'Numeric',
                position: 'bottom',
                fields: ['data1'],
                grid: true,
                label: {
                    renderer: Ext.util.Format.numberRenderer('0,0')
                },
                minimum: 0
            }, {
                type: 'Category',
                position: 'left',
                fields: ['name'],
                label: {
                   style:{
                        font:'bold 11px Arial',
                        whiteSpace:'normal'                    
                   }
                }
            }],
            series: [{
                type: 'bar',
                axis: 'bottom',
                xField: 'name',
                yField: 'data1',
                highlight: true,
                tips: {
                      trackMouse: true,
                      width: 250,
                      height: 28,
                      renderer: function(storeItem, item) {
                        this.setTitle(storeItem.get('name') + ': ' + storeItem.get('data1') + ' Users');
                      }
                    },
                label: {
                    display: 'insideEnd',
                    field: 'data1',
                    renderer: Ext.util.Format.numberRenderer('0'),
                    orientation: 'horizontal',
                    color: '#333',
                   'text-anchor': 'middle'
                },
                    xField: 'name',
                    yField: ['data1']
            }]
        });
        }
    It will be a great help if a solution that helps the chart to distribute x-axis(single column) uniformly across the above mentioned scenarios can be achieved. Please help me with the code change.

    Thanks,
    Vedvrat

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,074
    Answers
    3500
    Vote Rating
    854
    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


    In your series, be careful of using duplicate configs, you have two xField and two yField and may lead to confusing. Last one wins.

    So currently it works good if things increment by two but you want labels like the first image?
    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
    Sep 2010
    Posts
    9
    Vote Rating
    0
    VedvratSharma is on a distinguished road

      0  

    Default


    Thanks for pointing out the duplicate xfield, yfield.

    Yes, i need a uniform label spread.
    So ideally it should be a unique label not a repeatation of labels as displayed in first image.



  4. #4
    Sencha User
    Join Date
    Apr 2011
    Location
    Northern Virginia
    Posts
    15
    Vote Rating
    0
    trebor is on a distinguished road

      0  

    Default


    Any resolution on this - seeing same problem in 4.2.0

    thanks