Quantcast
Channel: SCN : All Content - All Communities
Viewing all articles
Browse latest Browse all 3276

Problem getting VIZ Charts to consume my JSON data

$
0
0

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


Viewing all articles
Browse latest Browse all 3276

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>