JSON Renders in JSFiddle but Fails in Flexmonster Native

Answered
Kapil Kanagal asked on October 20, 2021

Hey Team,
 
I am running into a very curious issue in which my JSON will render in JSFiddle, but whenever I try to render via the Flexmonster API in my code it shows as blank although I see the JSON data in the console after printing. For reference, I will attach my JSON (which is not nested) as well as screenshots of the Flexmonster API vs JSFiddle. 
 
Here is my JSFiddle implementation which works great: https://jsfiddle.net/Lgyrbd5j/2/
Is this an issue with the API itself? I was really hoping to make a subscription to the product if we can get it to work, but I am not sure what the root cause of an issue like this is.
 
Thanks in advance.
 

13 answers

Public
Mykhailo Halaida Mykhailo Halaida Flexmonster October 21, 2021

Hi Kapil,
 
Thank you for raising your support ticket.
 
So far, the nature of the described issue is not entirely clear to us – the provided JSON data set seems to be working fine when loaded locally on our side.
 
Perhaps, you could provide us with a sample project where this issue is reproducible so that we could deploy and test it out?
 
As an alternative, I'm attaching a simple HTML file with a Flexmonster instance and the dataset you've provided. Feel free to modify it so that the reported behavior is reproduced and send it back to us – that would be helpful as well. 
 
Looking forward to your response.
 
Best regards,
Mykhailo

Attachments:
index.html

Public
Kapil Kanagal October 21, 2021

Hi Mykhailo,
 
No problem -- we are looking to use Flexmonster for our systems so maybe it makes sense to chat in person. Please email me at kkanagal@bamfunds.com and we can coordinate a time to discuss further and price out the full version as well.
 
Thanks,
Kapil

Public
Mykhailo Halaida Mykhailo Halaida Flexmonster October 22, 2021

Kapil,
 
Thank you for your fast response!
 
Please note that it is not yet clear to us what the technical issue is – it would help us a lot if you could provide some details, which I've requested in my previous response. This way, we'll be able to help you with your inquiry, either through written communication or, if necessary, through a live meeting.
 
In the meantime, feel free to send us an email to discuss licensing questions with our managers or if you want to share some private files/data that cannot be provided through the help center. 
 
Please let us know what you think.
 
Regards,
Mykhailo

Public
Kapil Kanagal October 26, 2021

Hi Mykhailo,
 
I am working in native JS and I believe I have set up all the columns in my report correctly for my Flexmonster object; however, when I render the page, it only displays 1 column. I am refreshing the data on an interval using this example. How can I get all my columns to render and display them in the order I have outlined in my report variable on load? Currently, I need to click on the arrow in the top right corner and select all the fields to display.
Thanks!
-Kapil

async function webRequest() {
let url = "portfolios/CFIN_BOT";
// await sleep(15000);
let response = await fetch(url, { method: 'GET'})
return response;
}

function updateData(data_passed) {
pivot.updateData({
data: JSON.parse(data_passed)
})
}

var report = {
dataSource: {
type: "json",
},
"slice": {
"rows": [{
"uniqueName": "symbol"
},
{
"uniqueName": "UL"
},
{
"uniqueName": "Expiry"
}
],
"columns": [{
"uniqueName": "[Measures]"
}],
"measures": [
{
"uniqueName": "Qty",
"active": true,
"aggregation": "sum"
},
{
"uniqueName": "Net PnL",
"active": true,
"aggregation": "sum"
},
{
"uniqueName": "Cumul Pnl",
"active": true,
"aggregation": "sum"
},
{
"uniqueName": "Trade PnL",
"active": true,
"aggregation": "sum"
},
{
"uniqueName": "price",
"active": true,
"aggregation": "sum"
},
{
"uniqueName": "delta",
"active": true,
"aggregation": "sum"
},
{
"uniqueName": "gamma",
"active": true,
"aggregation": "sum"
},
{
"uniqueName": "Dollar Delta",
"active": true,
"aggregation": "sum"
},
{
"uniqueName": "Dollar Gamma",
"active": true,
"aggregation": "sum"
},
{
"uniqueName": "vega",
"active": true,
"aggregation": "sum"
},
{
"uniqueName": "Weighted Vega",
"active": true,
"aggregation": "sum"
},
{
"uniqueName": "VIX Vega",
"active": true,
"aggregation": "sum"
},
{
"uniqueName": "theta",
"active": true,
"aggregation": "sum"
},
{
"uniqueName": "vanna",
"active": true,
"aggregation": "sum"
},
{
"uniqueName": "volga",
"active": true,
"aggregation": "sum"
},
{
"uniqueName": "Vol",
"active": true,
"aggregation": "average"
},
{
"uniqueName": "YDay Vol",
"active": true,
"aggregation": "average"
}
]
},
"formats": [{
"name": "rate_format",
"decimalPlaces": 4
}]
};


var pivot = new Flexmonster({
container: "#pivot-container",
componentFolder: "https://cdn.flexmonster.com/",
width: "100%",
height: 1000,
report: report,
reportcomplete: function() {
pivot.off("reportcomplete");
setInterval(
function() {
blarg()
},
60000
);
}
});

function blarg(){
return webRequest().then((resp) => resp.json()).then((idkIveLostMyWillToLive) => updateData(idkIveLostMyWillToLive))
}
Public
Mykhailo Halaida Mykhailo Halaida Flexmonster October 27, 2021

Hi Kapil,
 
Thank you for providing additional details on your issue, It is now clear to us what happens – please find the explanation below.
 
When the page loads, you use the defined report object in the Flexmonster constructor. The problem is, you initially define this report object without actual data, and if Flexmonster doesn't receive any data, the rest of the report (e.g., slice, formats, etc.) is not preserved.
 
To avoid this, specify an initial data set in your report – once you do, the rest of the report configurations will be saved and applied when you update the data.
 
Here's a modified HTML file based on the code you've sent us that showcases the approach described above.
 
Please let us know if this helps.
 
Kind regards,
Mykhailo

Attachments:
index.html

Public
Mykhailo Halaida Mykhailo Halaida Flexmonster November 3, 2021

Kapil,
 
How are you?
 
Just checking in to ask if you've found my last response helpful. Is the issue resolved?
 
We'd be happy to hear your feedback!
 
Best regards,
Mykhailo

Public
Kapil Kanagal November 3, 2021

Hi Mykhailo,
 
Doing well thanks! Hope you had a very happy Halloween. This worked in terms of resolving the issue for our problem. More broadly, is there a feature in flexmonster to group rows and create subheadings within the table?
 
Thanks,
Kapil

Public
Kapil Kanagal November 4, 2021

Hi Mykhailo,
 
Wanted to follow up with another question -- if I have a multiindex pandas dataframe, how can I convert it into the proper form and display as a hierarchical table in Flexmonster?
 
Thanks,
Kapil

Public
Mykhailo Halaida Mykhailo Halaida Flexmonster November 5, 2021

Hi Kapil,
 
Thank you, hope you had a great holiday as well! Good to hear the initial issue is resolved.
 
Answering your question regarding row grouping, you can group multiple fields into multilevel hierarchies, here's how. 
 
Speaking of passing data from a pandas dataframe, we cover this topic in our Integration with Jupyter Notebook guide – feel free to check it out.
 
Hope you find this helpful.
 
Regards,
Mykhailo

Public
Kapil Kanagal November 18, 2021

Hey Mykhailo,
Thanks for all of your help with this -- someone from our back office should be reaching out to your team shortly for the full-time license! We are excited to continue using Flexmonster as a part of our workflow.
One question a member of our team had was if it would be possible to save down columns that are created from the "Add calculated value" button for future use or whenever they reload the page. Screenshot attached. Is there some parameter I can pass within the JS to do so?
Thanks for all of your help and look forward to speaking soon.
-Kapil

Public
Nadia Khodakivska Nadia Khodakivska Flexmonster November 19, 2021

Hello, Kapil,
 
Thank you for writing to us.
 
Saving created calculated values requires saving the report. Flexmonster provides several ways to get the report from the component:

  1. getReport() API call
  2. save() API call to save a report to the server or to the local file system
  3. click the Save button on the Toolbar

Check the following page to find more information: https://www.flexmonster.com/doc/save-and-restore-report/#save-report
 
Next, you can set the report for the component using these methods:

  1. setReport() API call
  2. open() API call to select a file from the local file system
  3. load() API call to load a file from a URL
  4. on the Toolbar, you can hover on the Open button and choose Local or Remote report.

Here you can find a detailed guide: https://www.flexmonster.com/doc/save-and-restore-report/
 
Please let us know if it works for you. Feel free to contact us if other questions arise.
 
Kind regards,
Nadia

Public
Nadia Khodakivska Nadia Khodakivska Flexmonster November 26, 2021

Hello,
 
Hope you are doing well.
 
Could you please confirm if the solution satisfies your needs?
 
Looking forward to your response.
 
Kind regards,
Nadia

Public
Nadia Khodakivska Nadia Khodakivska Flexmonster December 13, 2021

Hello,
 
Hope you are doing well.
 
We were wondering if the solution helped you. 
 
Looking forward to your feedback.
 
Kind regards,
Nadia

Please login or Register to Submit Answer