Hi,
I am pulling data using ajax and updating pivot after each refresh. Please see the simple code:
$.post( window.location, {data: JSON.stringify( data ) }, function(result, textStatus) {
pivot.updateData({ data: result });
pivot.runQuery( getSlice() );
pivot.setFormat({ name: "TFormat", decimalPlaces: 2 });
pivot.refresh();
}, "json");
Data is updated correctly but I saw that only first refresh works good, every next one changes name of all string fields adding "Count of FIELDNAME ) to the name.
I would appreciate any help, pointers or experiments I could try
Hi Dawid!
Probably those fields were detected automatically as numbers. To prevent autodetection you can predefine field types https://www.flexmonster.com/doc/managing-data-presentation-json
If everything is fine with your data types you also can change labels via localization https://www.flexmonster.com/doc/localizing-component/
Does it work for you?
Regards,
Dmytro
Hi, thanks for the response,
yes, I am defining field types in JSON code ( at the beginning as in your example )
I want to understand what is changing after update. Looks like this is because of this line:
pivot.setFormat({ name: "TFormat", decimalPlaces: 2 });
Everything works ok if I remove it. But I wanna see only 2 decimal places so I can't remove it permanently.
Will be thankful for the support,
Thanks,
Dawid
Dawid,
Could you please send me a data sample? It will help us to resolve your issue much faster.
Thanks,
Dmytro
Sure ,please take a took:
[
{
u'function': {u'caption': u'Function', u'type': u'string'},
u'v': {u'caption': u'vol1', u'type': u'number'},
u'id': {u'caption': u'ID', u'type': u'string'},
u'week': {u'caption': u'Week', u'type': u'string'},
u'process': {u'caption': u'Process', u'type': u'string'},
u'type': {u'caption': u'Type', u'type': u'string'},
u'hours': {u'caption': u'Hours', u'type': u'number'},
u'size': {u'caption': u'Size', u'type': u'string'}
},
{
u'function': u'tsi',
u'v': 367.0,
u'id': u'233x',
u'week': '2018-14',
u'process': u'tsi',
u'type': u'0-39',
u'hours': 7.64111111111,
u'size': u'Large'
},
{
u'function': u'tsi',
u'v': 238.0,
u'id': u'233x',
u'week': '2018-14',
u'process': u'tsi',
u'type': u'120-159',
u'hours': 4.12111111111,
u'size': u'Large'
},
{
u'function': u'tsu',
u'v': 135.0,
u'id': u'233x',
u'week': '2018-14',
u'process': u'tsu',
u'type': u'160-199',
u'hours': 2.50222222222,
u'size': u'Large'
}
]
Hello, Dawid,
Thank you for sharing your data sample! It has really helped us.
You use setFormat
as following:
pivot.setFormat({ name: "TFormat", decimalPlaces: 2 });
We suggest to use it a little bit differently:
a) if you want to apply this number format to all numerical values, please set name
property as an empty string
pivot.setFormat({ name: "", decimalPlaces: 2 });
b) if you want to apply "TFormat"
to some specific measure, for example, "Price"
, you need to specify this measure as a second parameter
pivot.setFormat({ name: "TFormat", decimalPlaces: 2 }, "Price");
In both cases, "Count of FIELDNAME"
should not appear anymore.
Does it help?
Regards,
Tanya
Yes, it helps a lot!
Thanks,
Dawid