We have updated Flexmonster Software License Agreement, effective as of September 30, 2024. Learn more about what’s changed.

How to slice data from multiple json api sources

Answered
Michael Odal asked on November 7, 2019

Hi,
I have added the ability to connect to multiple Json Api data sources using functions similar to the one below, at the click of a button(s):
function connectData1(){flexmonster.connectTo({type: "json",
filename: filename: 'https://cdn.flexmonster.com/data/data.json'
});
}
function connectData2(){flexmonster.connectTo({type: "json",
filename: filename: 'https://cdn.flexmonster.com/data/data.json'
});
}
All the Json key:value pairs have similar headers and I would like to use them to slice the data, regarless of which Api is called

4 answers

Public
Illia Yatsyshyn Illia Yatsyshyn Flexmonster November 7, 2019

Hello, Michael,
 
Thank you for your question.
 
To update your data with several files consisting of identical keys with different values saving the slice settings, we kindly recommend using the following approach.
 
Use the updateData() method which will update your data without changing the desired slice. Slice can be adjusted by default or by the user. Learn more about the method here: https://www.flexmonster.com/api/updatedata/
 
Also, find out an example we have created for you by the link below: http://jsfiddle.net/flexmonster/d8eoum42/
 
Please note, that if you desire to display several files in the one pivot table you will need to merge your files on the server-side. Flexmonster component will process such the file as a normal single-origin one.
 
We hope it helps.
Feel free to contact us in case of additional questions.
 
Best Regards,
Illia

Public
Michael Odal November 7, 2019

Hi Illia,
Thanks for the feedback. However, this is more confusing. 
I'm using json url. Where would I define the rows and columns?
would something like this work?
function connectData1() {
flexmonster.updateData({
type: "json",
filename: 'http://localhost:8080/Example/rest/test'
},
slice: {
rows: [
{ uniqueName: "[Measures]" },
{ uniqueName: "Color" }
],
columns: [
{ uniqueName: "Category" }
],
measures: [
{ uniqueName: "Price" }
]
}
});
}

Public
Illia Yatsyshyn Illia Yatsyshyn Flexmonster November 7, 2019

Hello, Michael,
 
Thank you for providing more details.
 
Our team kindly recommends checking out the setReport method which allows you to adjust the specific slice for each data source.
 
Find out an example we have prepared by the link: http://jsfiddle.net/flexmonster/15jdrk07/.
 
We hope it fits your needs.
Please, contact us in case of additional questions.
 
Kind Regards,
Illia

Public
Michael Odal November 8, 2019

Thank you very much. This has worked
Most appreciated
 
Michael

Please login or Register to Submit Answer