PDA

View Full Version : [OPEN] How to restrict duplication of values in X-Axis



nnimmakayala
19 Jul 2012, 6:35 AM
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
}
}
]
});



37325







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.

scottmartin
19 Jul 2012, 10:09 AM
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.

nnimmakayala
19 Jul 2012, 8:23 PM
37356

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.

37357


can you please reply soon.

nnimmakayala
19 Jul 2012, 8:47 PM
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.....).

redraid
20 Jul 2012, 1:47 AM
Remove or filter duplicates from store.

scottmartin
20 Jul 2012, 6:43 AM
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.

scottmartin
20 Jul 2012, 6:56 AM
Reported as bug.

Scott.

evant
22 Jul 2012, 6:38 PM
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.



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'
}]
});
});