This commit is contained in:
v-makgal 2017-04-06 15:45:13 +03:00
Родитель 11baceec31
Коммит 5d1015c70b
8 изменённых файлов: 167 добавлений и 62 удалений

5
.gitignore поставляемый Normal file
Просмотреть файл

@ -0,0 +1,5 @@
node_modules
.tmp
dist
.api
*.log

14
.travis.yml Normal file
Просмотреть файл

@ -0,0 +1,14 @@
os:
- linux
sudo: required
dist: trusty
language: node_js
node_js:
- "7"
install:
- npm install
script:
- npm run lint
- npm run package
notifications:
email: false

Просмотреть файл

@ -1,3 +1,15 @@
{
"name": "visual"
"name": "visual",
"scripts": {
"postinstall": "pbiviz update 1.6.0",
"pbiviz": "pbiviz",
"package": "pbiviz package",
"lint": "tslint -r \"node_modules/tslint-microsoft-contrib\" \"+(src)/**/*.ts\"",
"start": "pbiviz start"
},
"devDependencies": {
"tslint": "^4.4.2",
"tslint-microsoft-contrib": "^4.0.0",
"powerbi-visuals-tools": "1.6.2"
}
}

Просмотреть файл

@ -9,7 +9,7 @@
"supportUrl": "http://community.powerbi.com/",
"gitHubUrl": "https://github.com/microsoft/PowerBI-visuals-forcasting-exp"
},
"apiVersion": "1.2.0",
"apiVersion": "1.6.0",
"author": {
"name": "Microsoft",
"email": "pbicvsupport@microsoft.com"

Просмотреть файл

@ -9,11 +9,11 @@ module powerbi.extensibility.visual {
* @param {T} defaultValue - Default value of desired property.
*/
export function getValue<T>(objects: DataViewObjects, objectName: string, propertyName: string, defaultValue: T ): T {
if(objects) {
if (objects) {
let object = objects[objectName];
if(object) {
if (object) {
let property: T = <T>object[propertyName];
if(property !== undefined) {
if (property !== undefined) {
return property;
}
}
@ -31,19 +31,17 @@ module powerbi.extensibility.visual {
* @param {T} defaultValue - Default value of desired property.
*/
export function getValueMinMax<T>(objects: DataViewObjects, objectName: string, propertyName: string, defaultValue: T, minVal: T, maxVal: T ): T {
if(objects) {
if (objects) {
let object = objects[objectName];
if(object) {
if (object) {
let property: T = <T>object[propertyName];
if(property < minVal)
{
if (property < minVal) {
return minVal;
}
if(property > maxVal)
{
if (property > maxVal) {
return maxVal;
}
if(property !== undefined) {
if (property !== undefined) {
return property;
}
}
@ -62,17 +60,15 @@ module powerbi.extensibility.visual {
* @param {T} defaultValue - Default value of desired property.
*/
export function getValueNumberMinMax(objects: DataViewObjects, objectName: string, propertyName: string, defaultValue: number, minValue: number, maxValue: number ) {
if(objects) {
if (objects) {
let object = objects[objectName];
if(object) {
if (object) {
let property = object[propertyName];
if(property !== undefined) {
if(property > maxValue)
{
if (property !== undefined) {
if (property > maxValue) {
return maxValue;
}
if(property < minValue)
{
if (property < minValue) {
return minValue;
}
return property;
@ -87,44 +83,41 @@ module powerbi.extensibility.visual {
* Gets conditional property value for a particular object of type string
*
* @function
* @param {string} inVal - current value of parameter
* @param {string} inVal - current value of parameter
* @param {string} contrVal - control value
* @param {string} contrVal2Compare - specific string to be compared with contrVal
* @param {boolean} logic - true / false "logic"
* @param {string} outValIfCondTrue - output value if comparison (contrVal == contrVal2Compare) comes out as "logic"
* @param {string} outValIfCondTrue - output value if comparison (contrVal == contrVal2Compare) comes out as "logic"
*/
export function ifStringReturnString(inVal: string, contrVal: string, contrVal2Compare: string, outValIfCondTrue: string, logic: boolean, applyNow:boolean)
{
if(applyNow && contrVal == contrVal2Compare && logic == true)
export function ifStringReturnString(inVal: string, contrVal: string, contrVal2Compare: string, outValIfCondTrue: string, logic: boolean, applyNow: boolean) {
if (applyNow && contrVal === contrVal2Compare && logic === true)
return outValIfCondTrue;
if(applyNow && contrVal != contrVal2Compare && logic == false)
if (applyNow && contrVal !== contrVal2Compare && logic === false)
return outValIfCondTrue;
return inVal;
}
export function ifStringReturnStringClustersMethod(numClustersMethods:string , numOfClusters:string)
{
if(numOfClusters!="auto")
return "None"
if(numOfClusters=="auto" && numClustersMethods=="None")
return "fast"
export function ifStringReturnStringClustersMethod(numClustersMethods: string, numOfClusters: string) {
if (numOfClusters !== "auto")
return "None";
if (numOfClusters === "auto" && numClustersMethods === "None")
return "fast";
return numClustersMethods;
}
}
export function inMinMax(a: number, mi: number, ma: number)
{
if(a<mi)
export function inMinMax(a: number, mi: number, ma: number) {
if (a < mi)
return mi;
if(a>ma)
if (a > ma)
return ma;
return a;
}
/**
* Gets property value for a particular object in a category.
@ -139,13 +132,13 @@ export function ifStringReturnStringClustersMethod(numClustersMethods:string , n
export function getCategoricalObjectValue<T>(category: DataViewCategoryColumn, index: number, objectName: string, propertyName: string, defaultValue: T): T {
let categoryObjects = category.objects;
if(categoryObjects) {
if (categoryObjects) {
let categoryObject: DataViewObject = categoryObjects[index];
if(categoryObject) {
if (categoryObject) {
let object = categoryObject[objectName];
if(object) {
if (object) {
let property: T = <T>object[propertyName];
if(property !== undefined) {
if (property !== undefined) {
return property;
}
}

Просмотреть файл

@ -75,12 +75,12 @@ module powerbi.extensibility.visual {
this.imageDiv.appendChild(this.imageElement);
this.settings_forecastPlot_params = <VisualSettingsForecastPlotParams>{
forecastLength: 10,
seasonType: "Automatic",
errorType: "Automatic",
trendType: "Automatic",
dampingType: "Automatic",
dampingType: "Automatic",
targetSeason: "Automatic"
};
@ -91,7 +91,7 @@ module powerbi.extensibility.visual {
};
this.settings_graph_params = <VisualGraphParams>{
dataCol: "orange",
forecastCol: "red",
percentile: 40,
@ -100,7 +100,7 @@ module powerbi.extensibility.visual {
};
this.settings_additional_params = <VisualAdditionalParams>{
showWarnings: false,
showInfo: true,
textSize: 10
@ -131,19 +131,19 @@ module powerbi.extensibility.visual {
percentile: getValue<number>(dataView.metadata.objects, 'settings_conf_params', 'percentile', 80),
upperConfIntervalFactor: getValue<string>(dataView.metadata.objects, 'settings_conf_params', 'upperConfIntervalFactor', "0.5"),
}
};
this.settings_graph_params = <VisualGraphParams>{
dataCol: getValue<string>(dataView.metadata.objects, 'settings_graph_params', 'dataCol', "orange"),
forecastCol: getValue<string>(dataView.metadata.objects, 'settings_graph_params', 'forecastCol', "red"),
percentile: getValue<number>(dataView.metadata.objects, 'settings_graph_params', 'percentile', 40),
weight: getValue<number>(dataView.metadata.objects, 'settings_graph_params', 'weight', 10),
}
};
this.settings_additional_params = <VisualAdditionalParams>{
showWarnings: getValue<boolean>(dataView.metadata.objects, 'settings_additional_params', 'showWarnings', false),
showInfo: getValue<boolean>(dataView.metadata.objects, 'settings_additional_params', 'showInfo', true),
textSize: getValue<number>(dataView.metadata.objects, 'settings_additional_params', 'textSize', 10)
}
};
let imageUrl: string = null;
if (dataView.scriptResult && dataView.scriptResult.payloadBase64) {
@ -170,33 +170,31 @@ module powerbi.extensibility.visual {
switch (objectName) {
case 'settings_forecastPlot_params':
if(this.settings_forecastPlot_params.trendType!="None")
{
if (this.settings_forecastPlot_params.trendType !== "None") {
objectEnumeration.push({
objectName: objectName,
properties: {
forecastLength: Math.round(inMinMax(this.settings_forecastPlot_params.forecastLength,1,1000000)),
forecastLength: Math.round(inMinMax(this.settings_forecastPlot_params.forecastLength, 1, 1000000)),
trendType: this.settings_forecastPlot_params.trendType,
dampingType: this.settings_forecastPlot_params.dampingType,
errorType: this.settings_forecastPlot_params.errorType,
seasonType: this.settings_forecastPlot_params.seasonType,
targetSeason:this.settings_forecastPlot_params.targetSeason
targetSeason: this.settings_forecastPlot_params.targetSeason
},
selector: null
});
}
else
{
else {
objectEnumeration.push({
objectName: objectName,
properties: {
forecastLength: Math.round(inMinMax(this.settings_forecastPlot_params.forecastLength,1,1000000)),
forecastLength: Math.round(inMinMax(this.settings_forecastPlot_params.forecastLength, 1, 1000000)),
trendType: this.settings_forecastPlot_params.trendType,
errorType: this.settings_forecastPlot_params.errorType,
seasonType: this.settings_forecastPlot_params.seasonType,
seasonType: this.settings_forecastPlot_params.seasonType,
},
selector: null
});
});
}
break;
@ -205,7 +203,7 @@ module powerbi.extensibility.visual {
objectName: objectName,
properties: {
show: this.settings_conf_params.show,
percentile: inMinMax(this.settings_conf_params.percentile,0,99),
percentile: inMinMax(this.settings_conf_params.percentile, 0, 99),
upperConfIntervalFactor: this.settings_conf_params.upperConfIntervalFactor
},
selector: null
@ -227,7 +225,7 @@ module powerbi.extensibility.visual {
break;
case 'settings_additional_params':
if (this.settings_additional_params.showInfo == true) {
if (this.settings_additional_params.showInfo === true) {
objectEnumeration.push({
objectName: objectName,

Просмотреть файл

@ -8,7 +8,7 @@
"out": "./.tmp/build/visual.js"
},
"files": [
".api/v1.2.0/PowerBI-visuals.d.ts",
".api/v1.6.0/PowerBI-visuals.d.ts",
"src/objectEnumerationUtility.ts",
"src/visual.ts"
]

83
tslint.json Normal file
Просмотреть файл

@ -0,0 +1,83 @@
{
"rules": {
"class-name": true,
"comment-format": [
true,
"check-space"
],
"indent": [
true,
"spaces"
],
"no-duplicate-variable": true,
"no-eval": true,
"no-internal-module": false,
"no-trailing-whitespace": true,
"no-unsafe-finally": true,
"no-var-keyword": true,
"one-line": [
true,
"check-open-brace",
"check-whitespace"
],
"quotemark": [
false,
"double"
],
"semicolon": [
true,
"always"
],
"triple-equals": [
true,
"allow-null-check"
],
"typedef-whitespace": [
true,
{
"call-signature": "nospace",
"index-signature": "nospace",
"parameter": "nospace",
"property-declaration": "nospace",
"variable-declaration": "nospace"
}
],
"variable-name": [
true,
"ban-keywords"
],
"whitespace": [
true,
"check-branch",
"check-decl",
"check-operator",
"check-separator",
"check-type"
],
"insecure-random": true,
"no-banned-terms": true,
"no-cookies": true,
"no-delete-expression": true,
"no-disable-auto-sanitization": true,
"no-document-domain": true,
"no-document-write": true,
"no-exec-script": true,
"no-function-constructor-with-string-args": true,
"no-http-string": [
true,
"http://www.example.com/?.*",
"http://www.examples.com/?.*"
],
"no-inner-html": true,
"no-octal-literal": true,
"no-reserved-keywords": true,
"no-string-based-set-immediate": true,
"no-string-based-set-interval": true,
"no-string-based-set-timeout": true,
"non-literal-require": true,
"possible-timing-attack": true,
"react-anchor-blank-noopener": true,
"react-iframe-missing-sandbox": true,
"react-no-dangerous-html": true
}
}