Guys, I am a bit upset here... Documentation is really poor at this stage. Some things mentioned in previouse version of api for Custom Visuals no longer work in new api. Most of the information I can't find at all... Anyway, I am struggaling here to get the colors working and I would like to understand the flow in the code for Sample Bar Chart.
So, there is a function to show properties on UI, called enumerateObjectInstances. In the BarChart sample, we are doing this by looping through Categories (Apple, Orange, Plumb) and pushing the (Label - Color picker) pair to the UI. At this point we already have color as part of our Data Point, So, making total sense.
Now, to assign a color to data point, we are going to the visualTransform function. And this is where I get some issues understanding the flow.
1) We get a colorPalette. Just a simple array of all avalable colors.
2) Now depending on count of Values and Categories, we need to get max, we assign a default color to the the Category.
3) Now before setting value for Data Point, we call function getCategoricalObjectValue. I understand, that this function goes for Apple and cheking if any colour was already assigned before to Apple, if not set the default from step 2. So, basically, if we run it first time, we dont have any colors assigned, so all categories pick the color from default.
Now, the interesting thing for me here is that when we have categorical data set, and we run the first time, category.objects is even dont exsts (in getCategoricalObjectValue function). However, when I changed the color for one of the Category, the update is trigered and I can see that now each Category will have object assign to it, kind of binding Category to Object Fill. I am missing this link guys. I don't understand at which point that link is happening..
Please help
Thanks
Nick