1. Create a transient chart object with some dimensions, one measure (qDef): Count(Country) and two expressions (qExpressions): Count(1) and Sum(CategoryID). The identifier of the object (qId) is BC01. The initial data fetch is composed of the first three rows (qHeight is 3) from the top left. The active expression (qActiveExpression) is 0, which corresponds in this example to Count(1)). qGrouping is set to C in qMeasures to enable the measure of the chart to change on the fly.
The client sends:
{
"jsonrpc": "2.0",
"id": 1,
"method": "CreateSessionObject",
"handle": 1,
"params": [
{
"qInfo": {
"qId": "BC01",
"qType": "Chart"
},
"qHyperCubeDef": {
"qStateName": "$",
"qDimensions": [
{
"qLibraryId": "",
"qNullSuppression": false,
"qDef": {
"qGrouping": "N",
"qFieldDefs": [
"City",
"=Count(CategoryID)",
"Region"
],
"qFieldLabels": [
""
]
}
}
],
"qMeasures": [
{
"qLibraryId": "",
"qSortBy": {
"qSortByState": 0,
"qSortByFrequency": 0,
"qSortByNumeric": 0,
"qSortByAscii": 0,
"qSortByLoadOrder": 1,
"qSortByExpression": 0,
"qExpression": {
"qv": ""
}
},
"qDef": {
"qLabel": "",
"qDescription": "",
"qTags": [
"tags"
],
"qGrouping": "C",
"qDef": "Count(Country)",
"qExpressions": [
"Count(1)",
"Sum(CategoryID)"
],
"qActiveExpression": 0
}
}
]
}
}
]
}
The engine returns:
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"qReturn": {
"qType": "GenericObject",
"qHandle": 2
}
},
"change": [
3
]
}
The chart is created and the handle of the object is 2.
2. Check that the active expression is Count(1) using the GetLayout method.
The client sends:
{
"jsonrpc": "2.0",
"id": 2,
"method": "GetLayout",
"handle": 2,
"params": []
}
The engine returns:
{
"jsonrpc": "2.0",
"id": 2,
"result": {
"qLayout": {
"qInfo": {
"qId": "BC01",
"qType": "Chart"
},
"qSelectionInfo": {},
"qHyperCube": {
"qStateName": "$",
"qSize": {
"qcx": 2,
"qcy": 7532
},
"qDimensionInfo": [
{
"qFallbackTitle": "City",
"qApprMaxGlyphCount": 30,
"qCardinal": 7532,
"qSortIndicator": "N",
"qGroupFallbackTitles": [
"City",
"=Count(CategoryID)",
"Region"
],
"qGroupPos": 0,
"qStateCounts": {
"qLocked": 0,
"qSelected": 0,
"qOption": 7532,
"qDeselected": 0,
"qAlternative": 0,
"qExcluded": 0,
"qSelectedExcluded": 0,
"qLockedExcluded": 0
},
"qTags": [
"$text"
],
"qDimensionType": "D",
"qGrouping": "N",
"qNumFormat": {
"qType": "R",
"qnDec": 14,
"qUseThou": 1,
"qFmt": "##############",
"qDec": ".",
"qThou": ","
},
"qIsAutoFormat": true,
"qGroupFieldDefs": [
"City",
"=Count(CategoryID)",
"Region"
]
}
],
"qMeasureInfo": [
{
"qFallbackTitle": "Count(1)",
"qApprMaxGlyphCount": 5,
"qCardinal": 0,
"qSortIndicator": "A",
"qNumFormat": {
"qType": "I",
"qnDec": 0,
"qUseThou": 1,
"qFmt": "###0",
"qDec": "."
},
"qMin": 1,
"qMax": 74,
"qIsAutoFormat": true,
"qAttrExprInfo": []
}
],
"qEffectiveInterColumnSortOrder": [
0,
1
],
"qGrandTotalRow": [
{
"qText": "17891",
"qNum": 17891,
"qElemNumber": -1,
"qState": "X",
"qIsTotalCell": true
}
],
"qDataPages": [],
"qPivotDataPages": [],
"qStackedDataPages": [],
"qMode": "S",
"qNoOfLeftDims": -1
}
}
}
}
The active expression is Count(1).
3. Change the measure of the chart on the fly so that the active expression becomes Sum(CategoryID) . This means that qActiveExpression in qMeasures should be set to 1.
The client sends:
{
"jsonrpc": "2.0",
"id": 3,
"method": "ApplyPatches",
"handle": 2,
"params": [
[
{
"qPath": "/qHyperCubeDef/qMeasures/0/qDef/qActiveExpression",
"qOp": "replace",
"qValue": "1"
}
],
true
]
}
The engine returns:
{
"jsonrpc": "2.0",
"id": 3,
"result": {},
"change": [
2
]
}
The active expression is Sum(CategoryID).
4. Use the GetLayout method to check that the active expression is Sum(CategoryID).
The client sends:
{
"jsonrpc": "2.0",
"id": 4,
"method": "GetLayout",
"handle": 2,
"params": []
}
The engine returns:
{
"jsonrpc": "2.0",
"id": 5,
"result": {
"qLayout": {
"qInfo": {
"qId": "BC01",
"qType": "Chart"
},
"qHasSoftPatches": true,
"qSelectionInfo": {},
"qHyperCube": {
"qStateName": "$",
"qSize": {
"qcx": 2,
"qcy": 7532
},
"qDimensionInfo": [
{
"qFallbackTitle": "City",
"qApprMaxGlyphCount": 30,
"qCardinal": 7532,
"qSortIndicator": "N",
"qGroupFallbackTitles": [
"City",
"=Count(CategoryID)",
"Region"
],
"qGroupPos": 0,
"qStateCounts": {
"qLocked": 0,
"qSelected": 0,
"qOption": 7532,
"qDeselected": 0,
"qAlternative": 0,
"qExcluded": 0,
"qSelectedExcluded": 0,
"qLockedExcluded": 0
},
"qTags": [
"$text"
],
"qDimensionType": "D",
"qGrouping": "N",
"qNumFormat": {
"qType": "R",
"qnDec": 14,
"qUseThou": 1,
"qFmt": "##############",
"qDec": ".",
"qThou": ","
},
"qIsAutoFormat": true,
"qGroupFieldDefs": [
"City",
"=Count(CategoryID)",
"Region"
]
}
],
"qMeasureInfo": [
{
"qFallbackTitle": "Sum(CategoryID)",
"qApprMaxGlyphCount": 1,
"qCardinal": 0,
"qSortIndicator": "A",
"qNumFormat": {
"qType": "U",
"qnDec": 0,
"qUseThou": 0
},
"qMin": 0,
"qMax": 0,
"qIsAutoFormat": true,
"qAttrExprInfo": []
}
],
"qEffectiveInterColumnSortOrder": [
0,
1
],
"qGrandTotalRow": [
{
"qText": "0",
"qNum": 0,
"qElemNumber": -1,
"qState": "X",
"qIsTotalCell": true
}
],
"qDataPages": [],
"qPivotDataPages": [],
"qStackedDataPages": [],
"qMode": "S",
"qNoOfLeftDims": -1
}
}
}
}
The active expression is now Sum(CategoryID).