<?xml version=“1.0” encoding=“UTF-8″?>
<sdkExtension
xmlns=“http://www.sap.com/bi/zen/sdk”
id=“com.sap.sample.jsondatasource”
title=“SAP Design Studio SDK Extension Sample JSON Data Source”
version=“14.0”
vendor=“visualbi”>
<component
id=“JsonDataSource”
title=“JSON Data Source”
tooltip=“JSON Data from openweather API”
icon=“res/icon.png”
handlerType=“datasource”>
<jsInclude>res/js/component.js</jsInclude>
<property
id=“Jsonurl”
title=“Valid Json url”
type=“Url”/>
<property
id=“hasHeaderRow”
title=“Has Header Row”
type=“boolean”/>
<property
id=“hasHeaderColumn”
title=“Has Header Column”
type=“boolean”/>
</component>
</sdkExtension>
</xml>
sap.designstudio.sdk.DataBuffer.subclass(“com.sap.sample.jsondatasource.JsonDataSource”, function() {
var that = this;
var _hasHeaderRow = false;
var _hasHeaderColumn = false;
var _jsonurl;
this.init = function() {
this.defineDimensions([{
key: “cols”,
text: “City”,
“axis”: “COLUMNS”,
“axis_index”: 0
}, {
key: “rows”,
text: “Date”,
“axis”: “ROWS”,
“axis_index”: 0
}], {
key: “measures”,
text: “Measures”,
containsMeasures: true,
members: [{
“key”: “measure”,
“text”: “Temprature”,
“scalingFactor”: 2,
“formatString”: “0.00 EUR;-0.00 EUR”
}]
});
};
this.jsonurl = function(value) {
if (value === undefined) {
return _jsonurl;
} else {
_jsonurl = value;
return this;
}
};
this.hasHeaderRow = function(value) {
if (value === undefined) {
return _hasHeaderRow;
} else {
_hasHeaderRow = value;
return this;
}
};
this.hasHeaderColumn = function(value) {
if (value === undefined) {
return _hasHeaderColumn;
} else {
_hasHeaderColumn = value;
return this;
}
};
this.afterUpdate = function() {
$.ajax({
async: false,
url: _jsonurl,
}).done(function(jsonText) {
processJsonText(jsonText);
});
};
function processJsonText(jsonText) {
var city = [];
var day=[];
city[0]=[“”,”Londen”,”Kiev”,”Moscow”,”Morins”];
day[0]=[“01-12-2014″];
for(var i=0;i<jsonText.list.length;i++){
day[i+1]=parseInt((JsonText.list[i].main.temp));
}
city[1]=day;
alert(city);
that.fillWithArray(city, that.hasHeaderRow(), that.hasHeaderColumn());
that.fireUpdate(true);
}
});
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
8 | |
7 | |
5 | |
4 | |
4 | |
4 | |
4 | |
3 | |
3 | |
3 |