-
Notifications
You must be signed in to change notification settings - Fork 144
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
module powerbi.extensibility.visual { | ||
/** | ||
* Gets property value for a particular object. | ||
* | ||
* @function | ||
* @param {DataViewObjects} objects - Map of defined objects. | ||
* @param {string} objectName - Name of desired object. | ||
* @param {string} propertyName - Name of desired property. | ||
* @param {T} defaultValue - Default value of desired property. | ||
*/ | ||
export function getValue<T>(objects: DataViewObjects, objectName: string, propertyName: string, defaultValue: T ): T { | ||
if(objects) { | ||
let object = objects[objectName]; | ||
if(object) { | ||
let property: T = object[propertyName]; | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
Jemdo
|
||
if(property !== undefined) { | ||
return property; | ||
} | ||
} | ||
} | ||
return defaultValue; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,4 +6,8 @@ p { | |
padding: 5px; | ||
|
||
} | ||
} | ||
|
||
.xAxis path { | ||
display: none; | ||
} |
2 comments
on commit 7602bb5
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How is this going to change in API 1.7.0, with parseSettings() ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The current template for new custom visuals have a settings.ts
file to help retrieve object values from the dataView. The visual.ts
already has a method called enumerateObjectInstances()
and parseSettings()
There is no need to create an objectEnumerationUtility.ts
file with helper methods anymore. In the settings.ts
file:
export class VisualSettings extends DataViewObjectsParser {
public dataPoint: dataPointSettings = new dataPointSettings();
public enableAxis: barChartXAxisSettings = new barChartXAxisSettings();
}
...
export class barChartXAxisSettings {
public show: boolean = true;
}
In your visual update()
method near the top add:
this.settings = BarChart.parseSettings(options && options.dataViews && options.dataViews[0]);
...
if (this.settings.enableAxis.show) {
let margins = BarChart.Config.margins;
height -= margins.bottom;
}
Disregard the changes for BarChartSettings
as you'll be using VisualSettings
I'm using API 1.9.0 and getting an error at this point when I try to build. It comes from the objectEnumerationUtility.ts file.
TYPESCRIPT /src/objectEnumerationUtility.ts : (15,21) Type 'DataViewPropertyValue' is not assignable to type 'T'. Type 'string' is not assignable to type 'T'.
I can see what it's trying to do (I think) by taking the type from the object property default rather than being explicit as there'll be different types of properties on the object (line 15). Sorry I'm new to Typescript and have tried to find a solution but think it's strange this isn't working. Maybe there could be something else wrong?