You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[Conditional formatting](https://docs.microsoft.com/en-us/power-bi/visuals/service-tips-and-tricks-for-color-formatting#conditional-formatting-for-visualizations) of custom properties is supported by updating `VisualObjectInstance` object's properties as enumerated under `enumerateObjectInstances` method.
3
-
4
-
See [commit](https://github.com/microsoft/powerbi-visuals-api/commit/8fe88399c5ba82feeec4541ce5bf8e02a3ecd15a) for what was added at this step.
2
+
[Conditional formatting](https://docs.microsoft.com/en-us/power-bi/visuals/service-tips-and-tricks-for-color-formatting#conditional-formatting-for-visualizations) of custom formatting properties is supported by setting formatting property `instanceKind` in `getFormattingModel` method.
3
+
For more info on conditional formatting click [here](https://learn.microsoft.com/en-us/power-bi/developer/visuals/conditional-format?tabs=getFormattingModel)
5
4
6
5
Conditional formatting can only be applied to the following property types:
7
6
* Color
@@ -10,25 +9,23 @@ Conditional formatting can only be applied to the following property types:
10
9
* Web URL
11
10
12
11
## Add a conditional color formatting entry in the format pane
13
-
To add the conditional color formatting button in the format pane for the desired object, under the `enumerateObjectInstances` method, make the following change:
12
+
To add the conditional color formatting button in the format pane for the desired object, under the `getFormattingModel` method, make the following change:
14
13
15
-
Via `propertyInstanceKind` property of enumerated `VisualObjectInstance`, list all the properties that you'd like to have the conditional formatting entry applied to in the format pane.
14
+
Define `instanceKind` property of required formatting property `descriptor` with the appropriate value.
16
15
Use `VisualEnumerationInstanceKinds` enum to declare the type of the desired format (constant, rule or both).
Using `createDataViewWildcardSelector` declared under `powerbi-visuals-utils-dataviewutils`, specify whether conditional formatting will be applied to instances, totals, or both. For more information, see [DataViewWildcard](https://docs.microsoft.com/en-us/power-bi/developer/visuals/utils-dataview#dataviewwildcard).
28
25
29
-
In `enumerateObjectInstances`, make the following changes to the objects you want to apply conditional formatting to:
26
+
In `BarChartFormattingSettingsModel`, make the following changes to the formatting properties you want to apply conditional formatting to:
30
27
31
-
* Replace the `VisualObjectInstance`'s `selector` value with a `dataViewWildcard.createDataViewWildcardSelector()` call. Specify the desired option from `DataViewWildcardMatchingOption` enum to define whether conditional formatting is applied to instances, totals, or both.
28
+
* Replace the formatting property `descriptor`'s `selector` value with a `dataViewWildcard.createDataViewWildcardSelector()` call. Specify the desired option from `DataViewWildcardMatchingOption` enum to define whether conditional formatting is applied to instances, totals, or both.
32
29
33
30
* Add the `altConstantValueSelector` property having the value previously defined for the `selector` property.
See [commit](https://github.com/Microsoft/PowerBI-visuals-sampleBarChart/commit/956923b641bb1eacb613bf55a91f77725bc42431) for how conditional formatting was applied to sample bar chart.
39
+
See [commit](https://github.com/Microsoft/PowerBI-visuals-sampleBarChart) for how conditional formatting was applied to sample bar chart.
Copy file name to clipboardExpand all lines: Tutorial/DataBinding.md
+6-7Lines changed: 6 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -57,26 +57,25 @@ Use the internal `name` defined in your dataRoles to reference each field.
57
57
58
58
For more information, see the section about [Data View Mapping](https://github.com/Microsoft/PowerBI-visuals/blob/master/Capabilities/DataViewMappings.md).
59
59
60
-
## Defining and Using `visualTransform`
60
+
## Defining and Using `createSelectorDataPoints`
61
61
DataView is the structure that PowerBI provides to your visual and it contains the queried data to be visualized.
62
62
However, DataView provides your data in different forms such as categorical and table forms. In this instance we're building a categorical visual and we will only need the use the categorical property on the DataView.
63
63
64
-
Defining visualTransform will allow you to convert DataView into a view model your visual will use.
64
+
Defining `createSelectorDataPoints` will allow you to convert options dataView into bar chart data points your visual will use.
65
65
IVisualHost is required because when defining individual data points, you will want to assign colors and selection to them.
66
66
67
67
```typescript
68
68
/**
69
-
* Function that converts queried data into a view model that will be used by the visual
69
+
* Function that converts queried data into bar chart data points that will be used by the visual
70
70
*
71
71
* @function
72
72
* @param{VisualUpdateOptions}options - Contains references to the size of the container
73
73
* and the dataView which contains all the data
74
74
* the visual had queried.
75
75
* @param{IVisualHost}host - Contains references to the host which contains services
See [commit](https://github.com/Microsoft/PowerBI-visuals-sampleBarChart/commit/3c6e8186436b63bf0cf97d2cdd5dde8aa8d08709) for what was added to visualTransform
Copy file name to clipboardExpand all lines: Tutorial/DataBoundObjects.md
+45-57Lines changed: 45 additions & 57 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,16 +9,13 @@ See [commit](https://github.com/Microsoft/PowerBI-visuals-sampleBarChart/commit/
9
9
## Define Object in Capabilities
10
10
Similar to static objects, we will define another object in the capabilities
11
11
`colorSelector` is the internal name that will be referenced in the `dataView`.
12
-
`displayName` is the name that will be shown on the property pane.
13
12
14
13
`fill` is a `StructuralObjectValue` and is not associated with a primitive type.
15
14
16
15
```typescript
17
16
"colorSelector": {
18
-
"displayName": "Data Colors",
19
17
"properties": {
20
18
"fill": {
21
-
"displayName": "Color",
22
19
"type": {
23
20
"fill": {
24
21
"solid": {
@@ -69,74 +66,65 @@ export function getCategoricalObjectValue<T>(category: DataViewCategoryColumn, i
69
66
See [objectEnumerationUtility.ts](https://github.com/Microsoft/PowerBI-visuals-sampleBarChart/blob/master/src/objectEnumerationUtility.ts) for source code.
70
67
71
68
## Defining Default Color and Retrieving Categorical Object from DataView
72
-
Each color is now associated with each category inside `dataView`. We will set each data point to its cooresponding color.
69
+
Each color is now associated with each category inside options dataView. We will set each data point to its corresponding color.
color: getCategoricalObjectValue<Fill>(category, i, 'colorSelector', 'fill', defaultColor).solid.color,
86
-
selectionId: host.createSelectionIdBuilder()
87
-
.withCategory(category, i)
88
-
.createSelectionId()
87
+
category: `${category.values[i]}`,
89
88
});
90
89
}
91
90
```
92
91
93
-
## Populate Property Pane with `enumerateObjectInstances`
94
-
`enumerateObjectInstances` is used to populate the property pane with objects.
92
+
## Populate Property Pane with `getFormattingModel`
93
+
`getFormattingModel` is used to populate the property pane with objects.
94
+
For more information [here](https://learn.microsoft.com/en-us/power-bi/developer/visuals/format-pane)
95
+
95
96
For this instance, we would like a color picker per category we have. Each category be rendered on the property pane.
97
+
We will do this by adding a populate method `populateColorSelector` to create corresponding bar chart data points color selector in format pane after building the data points in `update` method. This `populateColorSelector` method iterate through each data point with the associated color.
96
98
97
-
We will do this by adding an additional case to the switch statement for `colorSelector` and iterate through each data point with the associated color.
99
+
Selection is required to associate the color with a data point.
Copy file name to clipboardExpand all lines: Tutorial/ExtensibilityUtils.md
+3-1Lines changed: 3 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,6 +9,8 @@ PowerBI provides several tools that help to cover the main needs to build your o
9
9
5.[InteractivityUtils](https://www.npmjs.com/package/powerbi-visuals-utils-interactivityutils) is a set of functions and classes for implementation of cross-selection and cross-filtering for PowerBI custom visuals.
10
10
6.[FormattingUtils](https://www.npmjs.com/package/powerbi-visuals-utils-formattingutils) are interfaces for creating PowerBI custom visuals.
11
11
7.[SVGUtils](https://www.npmjs.com/package/powerbi-visuals-utils-svgutils) is a tool for SVG manipulations for PowerBI custom visuals.
12
+
8.[FormattingModelUtils](https://github.com/microsoft/powerbi-visuals-utils-formattingmodel) is a set of classes, interfaces and method help building format pane easily.
13
+
9.[OnObjectUtils](https://github.com/microsoft/powerbi-visuals-utils-onobjectutils) provides an easy way for your Power BI custom visual to emit subselections to Power BI, get and render outlines.
12
14
13
15
### How to install
14
16
To install the package you should run the following command in the directory with your current custom visual:
@@ -47,4 +49,4 @@ After that user can use all available module methods
47
49
.call(xAxis);
48
50
```
49
51
50
-
To get more information about SVGItils package, please check the following [documentation](https://github.com/Microsoft/powerbi-visuals-utils-svgutils/)
52
+
To get more information about SVGItils package, please check the following [documentation](https://github.com/Microsoft/powerbi-visuals-utils-svgutils/)
Copy file name to clipboardExpand all lines: Tutorial/HighContrastSupport.md
+7-7Lines changed: 7 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -65,7 +65,7 @@ In Sample Bar Chart, for example, all bars are drawn with 2 pixels thick foregro
65
65

66
66

67
67
68
-
Here is one place in the `visualTransform` function that was changed to support high-contrast, it is called as part of rendering during `update`:
68
+
Here is one place in the `createSelectorDataPoints` function that was changed to support high-contrast, it is called as part of rendering during `update`:
69
69
70
70
**before**
71
71
```typescript
@@ -89,6 +89,11 @@ Here is one place in the `visualTransform` function that was changed to support
0 commit comments