Skip to content

Instantly share code, notes, and snippets.

View erikwett's full-sized avatar

Erik Wetterberg erikwett

View GitHub Profile
//created from the mashup editor
app.createCube({
"qInitialDataFetch": [
{
"qHeight": 20,
"qWidth": 2
}
],
"qDimensions": [
{
@erikwett
erikwett / visualization_create.js
Last active March 25, 2017 21:32
Create a chart with Qlik Sense Visualization API
app.visualization.create('barchart', // a bar chart
["Case Owner Group", // one dimension
"=Avg([Case Duration Time])"], // one measure
{"title":"On the fly barchart"}). // set the title
then(function(vis){ // when its ready
vis.show("QV03"); // show the chart
});
initialProperties : {
qListObjectDef : {
qShowAlternatives : true,
qFrequencyMode : "V",
qSortCriterias : {
qSortByState : 1
},
qInitialDataFetch : [{
qWidth : 2,
qHeight : 50
dimension : {
type : "items",
label : "Dimensions",
ref : "qListObjectDef",
min : 1,
max : 1,
items : {
label : {
type : "string",
ref : "qListObjectDef.qDef.qFieldLabels.0",
app.createList({
"qFrequencyMode": "V",
"qDef": {
"qFieldDefs": [
"Department"
]
},
"qExpressions": [
{
"qLabel": "Closed Cases",
//part of the result from app.getList("MeasureList",callback)
{
qInfo: { qId: "SLJUwQj", qType: "measure"},
qMeta: {description:"", tags:["sales"], title:"Sales Quantity"},
qData: {tags:["sales"], title:"Sales Quantity"}
}
//part of the result from app.createGenericObject with custom qMeasureListDef
{
qInfo: {qId: "SLJUwQj", qType: "measure"},
qMeta: {description:"", tags:["sales"], title:"Sales Quantity"},
qData: {qMeasure:
{
qActiveExpression:0,
qDef:"Sum([Sales Quantity])",
qExpressions:[],
qGrouping:"N"
//a measure list definition that gives you more data on the measures
app.createGenericObject({
qInfo: {
qType: "MeasureList"
},
qMeasureListDef: {
qType: "measure",
qData: {
qMeasure: "/qMeasure"
}
//send a CreateSessionObject to the app (handle 1), request id 7
{"method":"CreateSessionObject",
"handle":1,
"params":[
{"qInfo":{"qId":"SheetList","qType":"SheetList"},
"qAppObjectListDef":{"qType":"sheet",
"qData":{"title":"/qMetaDef/title","description":"/qMetaDef/description",
"thumbnail":"/thumbnail","cells":"/cells","rank":"/rank","columns":"/columns","rows":"/rows"}
}
}
@erikwett
erikwett / support_snapshot.js
Last active December 5, 2017 13:24
Support snapshot in Qlik Sense extension
// turn snapshot support on in your extension
support: {
snapshot: true, //snapshot - include in story
export: true, //export to PDF, PowerPoint and image
exportData: true //export data to excel
}