Results 1 to 8 of 8

Thread: How to restrict duplication of values in X-Axis

  1. #1

    Default How to restrict duplication of values in X-Axis

    Code:
    var store = Ext.create('Ext.data.JsonStore', {
        fields: ['name', 'data1', 'data2', 'data3', 'data4', 'data5'],
        data: [
            { 'name': 'metric one',   'data1': 2, 'data2': 3, 'data3': 4, 'data4': 2,  'data5': 2 },
            { 'name': 'metric two',   'data1': 4,  'data2': 4,  'data3': 2, 'data4': 3, 'data5': 2  },
            { 'name': 'metric three', 'data1': 4,  'data2': 2,  'data3': 3, 'data4': 4, 'data5': 3  },
            { 'name': 'metric four',  'data1': 2,  'data2': 2, 'data3': 2,  'data4': 4,  'data5': 3 },
            { 'name': 'metric five',  'data1': 4,  'data2': 4,  'data3': 3, 'data4': 2, 'data5': 4 }
        ]
    });
    
    
    Ext.create('Ext.chart.Chart', {
        renderTo: Ext.getBody(),
        width: 500,
        height: 300,
        animate: true,
        autoScroll : true,
        store: store,
        axes: [
            {
                type: 'Numeric',
                position: 'left',
                fields: ['data1', 'data2'],
                label: {
                    renderer: Ext.util.Format.numberRenderer('2,2')
                },
                title: 'Sample Values',
                grid: true,
                minimum: 0
            },
            {
                type: 'Category',
                position: 'bottom',
                fields: ['name'],
                title: 'Sample Metrics'
            }
        ],
        series: [
            { 
                type: 'line',
                highlight: {
                    size: 7,
                    radius: 7
                },
                axis: 'left',
                xField: 'name',
                yField: 'data1',
                markerConfig: {
                    type: 'cross',
                    size: 4,
                    radius: 4,
                    'stroke-width': 0
                }
            },
            {
                type: 'line',
                highlight: {
                    size: 7,
                    radius: 7
                },
                axis: 'left',
                fill: true,
                xField: 'name',
                yField: 'data2',
                markerConfig: {
                    type: 'circle',
                    size: 4,
                    radius: 4,
                    'stroke-width': 0
                }
            }
        ]
    });

    chart.JPG







    In the line chart in the X-axis is having duplicate values..but in the x-axis values are should not be duplicate.
    the store for the chart is as follows



    var store = Ext.create('Ext.data.JsonStore', {
    fields: ['name', 'data1', 'data2', 'data3', 'data4', 'data5'],
    data: [
    { 'name': 'metric one', 'data1': 2, 'data2': 3, 'data3': 4, 'data4': 2, 'data5': 2 },
    { 'name': 'metric two', 'data1': 4, 'data2': 4, 'data3': 2, 'data4': 3, 'data5': 2 },
    { 'name': 'metric three', 'data1': 4, 'data2': 2, 'data3': 3, 'data4': 4, 'data5': 3 },
    { 'name': 'metric four', 'data1': 2, 'data2': 2, 'data3': 2, 'data4': 4, 'data5': 3 },
    { 'name': 'metric five', 'data1': 4, 'data2': 4, 'data3': 3, 'data4': 2, 'data5': 4 }
    ]
    });

    please help me.
    Last edited by scottmartin; 20 Jul 2012 at 6:48 AM. Reason: Please format code.. artifact in code

  2. #2
    Sencha - Support Team scottmartin's Avatar
    Join Date
    Jul 2010
    Location
    Houston, Tx
    Posts
    9,410
    Answers
    716

    Default

    So you do not want 2 different series to meet if they have the same value? What are you expecting to happen?

    Please correct me if I did not understand your question.

    Scott.

  3. #3

    Default

    chart1.jpg

    graph should not plot with duplicated values .In above graph values in x-axis are duplicated like (0,0,1,1,2,2,2,....).
    graph should plot with unique values like below.

    chart2.JPG


    can you please reply soon.

  4. #4

    Default

    when we are plotting 2 series of data in one chart the Y-axis is taking 2 values (0,0,1,1.....).is it possible for it to display it as one chart with single values (0,1.....).


  5. #5
    Sencha User
    Join Date
    May 2011
    Location
    Ukraine, Rivne
    Posts
    250
    Answers
    44

    Default

    Remove or filter duplicates from store.

  6. #6
    Sencha - Support Team scottmartin's Avatar
    Join Date
    Jul 2010
    Location
    Houston, Tx
    Posts
    9,410
    Answers
    716

    Default

    My mistake ... I was not looking at the axis. (I was concentrating on the values).

    Filtering the duplicates is the immediate solution, but this should still not happen.

    Scott.

  7. #7
    Sencha - Support Team scottmartin's Avatar
    Join Date
    Jul 2010
    Location
    Houston, Tx
    Posts
    9,410
    Answers
    716

    Default

    Reported as bug.

    Scott.

  8. #8
    Sencha Premium User evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    19,258
    Answers
    759

    Default

    This isn't a bug. You've specified the render as "2,2", which doesn't include any decimal places. This means all the values will get rounded to the nearest integer.

    Code:
    Ext.onReady(function() {
        var store = Ext.create('Ext.data.Store', {
            fields: ['name', 'data'],
            data: [{
                name: 'metric one',
                data: 2,
            }, {
                name: 'metric two',
                data: 4
            }, {
                name: 'metric three',
                data: 4
            }, {
                name: 'metric four',
                data: 2
            }, {
                name: 'metric five',
                data: 4
            }]
        });
    
        Ext.create('Ext.chart.Chart', {
            renderTo: Ext.getBody(),
            width: 600,
            height: 400,
            store: store,
            axes: [{
                type: 'Numeric',
                position: 'left',
                fields: ['data'],
                title: 'Sample Values',
                minimum: 0
            }, {
                type: 'Category',
                position: 'bottom',
                fields: ['name'],
                title: 'Sample Metrics'
            }],
            series: [{
                type: 'line',
                axis: 'left',
                xField: 'name',
                yField: 'data'
            }]
        });
    });
    Twitter - @evantrimboli
    Former Sencha framework engineer, available for consulting.
    As of 2017-09-22 I am not employed by Sencha, all subsequent posts are my own and do not represent Sencha in any way.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •