Skip to Content
0
May 02, 2016 at 08:29 PM

Problem getting VIZ Charts to consume my JSON data

37 Views

Experts,

I am working on a very basic viz chart SAPUI5 example. My preferred JSON that I want to use to populate the chart looks like this:

"data": [

{"object": {

"ave":".173",

"name":"Fergie Jenkins",

"team":"Chicago Cubs",

"OnBasePercentage":".250"

}}

,

{"object": {

"ave":".300",

"name":"Alfonso Soriano",

"team":"Chicago Cubs",

"OnBasePercentage":".375"

}}

,

{"object": {

"ave":".130",

"name":"Gaylord Perry",

"team":"San Francisco Giants",

"OnBasePercentage":".205"

}}

]

The above JSON doesn't work with these dimensions:

var dataSet = new sap.viz.ui5.data.FlattenedDataset({

dimensions: [

{ axis: 1, name: 'Player', value: "{name}" },

{ axis: 2, name: 'Team', value: "{team}" }

],

measures: [

{ name: 'Average', value: '{ave}' }

],

data: { path: "/data" }

});

Is there a way to tell this dimensions construct that I have a parent node in my JSON for each record of "object"? I tried {object.name}, but that did not work. Is there a syntax change I can make to reference the field values that would include the "object" reference somehow?

My chart works fine when I use the following JSON without the "object" wrapper, but this is not my preferred format:

"data": [

{

"AgentryObjectName": "",

"ave":".173",

"name":"Fergie Jenkins",

"team":"Chicago Cubs",

"OnBasePercentage":".250"

}

,

{

"AgentryObjectName": "",

"ave":".300",

"name":"Alfonso Soriano",

"team":"Chicago Cubs",

"OnBasePercentage":".375"

}

,

{

"AgentryObjectName": "",

"ave":".130",

"name":"Gaylord Perry",

"team":"San Francisco Giants",

"OnBasePercentage":".205"

}

]

Any help would be greatly appreciated. Thanks!

Jason Latko - Senior Product Developer at SAP