Qlik Community

New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

zoltan_farkas
New Contributor III

Creating HyperCubes

Hi,

I would like to create a HyperCube in my mashup, just a simple pie chart for demo purpose. I used this block of code but unfortunately something went wrong.

app.createCube({

qDimensions: [{

qDef: {

qFieldDefs: ["Product Group"]

}

}],

qMeasures: [{

qDef: {

qDef: "SUM([Margin Amount])",

qLabel: ""

}

}],

qInitialDataFetch: [{

qHeight: 20,

qWidth: 8

}]

}), function (reply) {

var valueArray = [];

$.each(reply.qHyperCube.qDataPages[0].qMatrix, function (index, value) {

if (!this[0].qIsEmpty) {

valueArray.push(this[1].qNum);

}

});

$("#pieChart").sparkline(valueArray,  {

type: 'pie',

width: $("#pieChart").width(),

height: $("#pieChart").height()

})

};

In the HTML I've created a div for the pieChart ID:

<div id="pieChart" style= "height: 200px; width: 200px;"></div>

And I am referencing to the sparkline library with this code:

require( ["js/qlik", "http://omnipotent.net/jquery.sparkline/2.1.2/jquery.sparkline.js"]

Any idea what could be the issue with this code?


Thank you,

Zoli

dberkesacn

Tags (3)
1 Solution

Accepted Solutions
m_schindler
Contributor II

Re: Creating HyperCubes

Hello Zoltan,

you have a typo (i marked it for you). Basically you wrote

     app.createCube(cube) , function(reply){};

but it should be

     app.createCube(cube, function(reply){ });

Zoltan Farkas schrieb:

Hi,

I would like to create a HyperCube in my mashup, just a simple pie chart for demo purpose. I used this block of code but unfortunately something went wrong.

app.createCube({

qDimensions: [{

qDef: {

qFieldDefs: ["Product Group"]

}

}],

qMeasures: [{

qDef: {

qDef: "SUM([Margin Amount])",

qLabel: ""

}

}],

qInitialDataFetch: [{

qHeight: 20,

qWidth: 8

}]

}), function (reply) {

var valueArray = [];

$.each(reply.qHyperCube.qDataPages[0].qMatrix, function (index, value) {

if (!this[0].qIsEmpty) {

valueArray.push(this[1].qNum);

}

});

$("#pieChart").sparkline(valueArray,  {

type: 'pie',

width: $("#pieChart").width(),

height: $("#pieChart").height()

})

};

In the HTML I've created a div for the pieChart ID:

<div id="pieChart" style= "height: 200px; width: 200px;"></div>

And I am referencing to the sparkline library with this code:

require( ["js/qlik", "http://omnipotent.net/jquery.sparkline/2.1.2/jquery.sparkline.js"]

Any idea what could be the issue with this code?


Thank you,

Zoli

dberkesacn

Mathias

2 Replies
m_schindler
Contributor II

Re: Creating HyperCubes

Hello Zoltan,

you have a typo (i marked it for you). Basically you wrote

     app.createCube(cube) , function(reply){};

but it should be

     app.createCube(cube, function(reply){ });

Zoltan Farkas schrieb:

Hi,

I would like to create a HyperCube in my mashup, just a simple pie chart for demo purpose. I used this block of code but unfortunately something went wrong.

app.createCube({

qDimensions: [{

qDef: {

qFieldDefs: ["Product Group"]

}

}],

qMeasures: [{

qDef: {

qDef: "SUM([Margin Amount])",

qLabel: ""

}

}],

qInitialDataFetch: [{

qHeight: 20,

qWidth: 8

}]

}), function (reply) {

var valueArray = [];

$.each(reply.qHyperCube.qDataPages[0].qMatrix, function (index, value) {

if (!this[0].qIsEmpty) {

valueArray.push(this[1].qNum);

}

});

$("#pieChart").sparkline(valueArray,  {

type: 'pie',

width: $("#pieChart").width(),

height: $("#pieChart").height()

})

};

In the HTML I've created a div for the pieChart ID:

<div id="pieChart" style= "height: 200px; width: 200px;"></div>

And I am referencing to the sparkline library with this code:

require( ["js/qlik", "http://omnipotent.net/jquery.sparkline/2.1.2/jquery.sparkline.js"]

Any idea what could be the issue with this code?


Thank you,

Zoli

dberkesacn

Mathias

zoltan_farkas
New Contributor III

Re: Creating HyperCubes

Wow, I should have run through my code one more time!

Thank you, Mathias.

Zoli