Forum Discussion
Cannot successfully implement color picker on visual using table mapping
- 8 years ago
Please this code snippet below to fix the issues with color picker:
private static getSelectionIds( dataView: DataView, host: IVisualHost ): powerbi.visuals.ISelectionId[] { const queryName: string = dataView.table.columns[0].queryName; return dataView.table.identity.map((identity: DataViewScopeIdentity) => { const categoryColumn: DataViewCategoryColumn = { source: { queryName, displayName: null }, values: null, identity: [identity] }; return host.createSelectionIdBuilder() .withCategory(categoryColumn, 0) .withMeasure(queryName) .createSelectionId(); }); }Ignat Vilesov,
Software Engineer
Microsoft Power BI Custom Visuals
- 8 years ago
Alright thank you !
For those with the same situation, I find a workaround.
You should use
d3.scale.ordinal().domain(data.map(d => d.dimension).range(color_library)
With color_library an array of color your users can pick ( I take 10 for my chart but you can use 3 or 20...).
Not the best solution, I have to admit but it works for now until I find something else :)
Thanks v-viig I get the logic but I don't know how it can be apply to my case as I don't have any value data (all my data are text format).
How can I go from
"table": {
"rows": {
"select": [
{"for": {
"in": "Details"
}},
{"for": {
"in": "Yaxis"
}},
{"for": {
"in": "Xaxis"
}},
{"for": {
"in": "Dim2"
}},
{"for": {
"in": "Dim1"
}}
]
},
"conditions": [{
"Details":{
"max": 1
},
"Yaxis":{
"max": 1
},
"Xaxis":{
"max": 1
},
"Dim1":{
"max": 1
},
"Dim2":{
"max": 1
}
}]
}to something similar to the examples 2 or 3
Don't have numbers? If so, there's no way to impelement desired behavior w/o using numbers.
Ignat Vilesov,
Software Engineer
Microsoft Power BI Custom Visuals
- v-viig8 years agoCommunity Champion
Correct. You should have numeric data column in a data set. Such column will allow grouping that required to implement desired behavior.
Ignat Vilesov,
Software Engineer
Microsoft Power BI Custom Visuals
- FR57028 years agoHelper I
Yes, I transform my data from text to numeric in my code, but what I get from my DataSource are all text data.
There no way to have this behaviour without numbers directly in my DataSource ? Or do I have to make all the transformation when I create my ViewModel/DataPoints in order to enable my color picker ?
- FR57028 years agoHelper I
Alright thank you !
For those with the same situation, I find a workaround.
You should use
d3.scale.ordinal().domain(data.map(d => d.dimension).range(color_library)
With color_library an array of color your users can pick ( I take 10 for my chart but you can use 3 or 20...).
Not the best solution, I have to admit but it works for now until I find something else :)