I'm working with an elementary example of stacked bar chart. I would like to define a different color for every series (apple, banana, ...).
However when I try to set chart-colors=["#aaa","#bbb",...] I get random colors as result.
Here is my example:
http://plnkr.co/edit/NWKM85zV5wgwtHu17gtX?p=preview
After debuging the angular-chart.js I figured out that all the colors are converted to RGB representation in function hexToRgb(hex) and this function does not support short HEX format #FFF but rather long #FFFFFF
Following code worked well
chart-colors="['#ffffff', '#ff0000', '#00ff00', '#0000ff']"
Related
so i have a dynamic list of text that i want to visualize in a wordcloud. sometimes some of the words are too long and they get dropped from the display. i can scale down the size of everything, but it's not always clear what scale i should get down to in order to prevent things from being dropped. i'd rather not fiddle with this and just accept some things are dropped. also, everything is in a shiny app and i have a slider to control scale if really needed. the problem though is i want my text colored by properties of the words in my dataset. in this example below you can see how each "word" has a color associated with it...
wc <- data.frame(
word = c("too big to fit this one is","red","green","blue"),
freq = c(2,1,2,3),
col = c("black","red","green","blue"),
stringsAsFactors = FALSE
)
>wc
word freq col
1 too big to fit this one is 2 black
2 red 1 red
3 green 2 green
4 blue 3 blue
wordcloud2(wc, color = wc$col)
this then draws the wordcloud but the first element is dropped and the colors don't drop too ("red" is colored black, "green" is colored red, and "blue" is colored green). i can't do wordcloud2(wc, color = col) like an aes style call in ggplot, the wordcloud does draw but all the text is clear... i can hover over it but not see any of it. anyone else work through this issue? thanks!!!
I am using below code to color my pies in Pie chart so that each pie will have the same color of its value range. This code is working fine.
for I = 1 to UBound (vntValues)
myseries.Points(I).Interior.color = Range(s).cells(I).interior.color
next I
I want to change the font color of each pie according to the its value range. I tried below code but its not working.
myseries.Points(I).Font.color = Range(s).cells(I).Font.color
Its giving the error as
object doesn't support this property or method.
Can you please help me with the correct method to do it.
Thanks.
Semi-tested:
mySeries.Points(I).DataLabel.Characters.Font.Color = Range(s).cells(I).Font.color
I have not been able to find much info on the RGBW color system, other than that the final W stands for 'white'. I thought you could form white perfectly well with just red, green and blue, so I do not understand the function of white here.
Searching StackOverflow, I've found this question about converting between RGB and RGBW. Both answers suggest this 'algorithm' for conversion:
// RGBW from RGB
R, G, B, W = R, G, B, min(R, G, B) // i.e. W=min(R,G,B)
// RGB from RGBW
R, G, B = R, G, B // throw away the W
This doesn't only look useless, it's also not true. My Android phone, running Cyanogenmod, has a light sensor that outputs RGBW (cat /sys/class/sensors/light_sensor/lux) and the white value is definitely not min(r,g,b). I've made a chart with the values:
(The X axis is time.)
The black line represents the white value (an actually white line would be rather difficult to see), the other colors are accurate (i.e. red line is the measured red value, etc.). From sight, I cannot determine any relation between white and the other colors, so it probably serves a function. I just cannot understand which.
It's this sensor: http://www.capellamicro.com.tw/EN/product_c.php?id=68&mode=16
And here is the source code that controls the sensor: https://github.com/mozilla-b2g/kernel-android-galaxy-s2-ics/blob/master/drivers/sensor/cm36651.c#L605-L630
That is all I've been able to figure out, but nothing contains info on what this white value represents.
That exactly it – you can't form white perfectly using only RGB LEDs. This is because the RGB colorspace is a small, pale fraction of the CIE-1931 XYZ space, and it’s distorted: incrementing an RGB values’ “R” by 1 is not at all qualitatively the same as incrementing its “G” value or “B” value, for example.
Just do a side by side comparison and the difference will be very, very clear. You can google “True white RGB led” and you'll learn a lot more; a good introduction is here: http://www.ledsmagazine.com/articles/print/volume-10/issue-6/features/understand-rgb-led-mixing-ratios-to-realize-optimal-color-in-signs-and-displays-magazine.html
I am having some trouble with applying a colour scale on circles on a scatterplot.
What I did to set up the scale was:
var color = d3.scale.ordinal()
.domain(d3.extent(dataset, function (d) { return parseFloat(d.Weight); }))
.range(["#D6F5D6", "#ADEBAD", "#84E184", "#5BD75B","#32CD32"]);
And then apply the color to the circles with:
.attr("fill", function (d) { return color(d.Weight) }
But from the graph I can tell that the colours are not correct, in fact I see some values that are higher that have a lighter colour. I think the problem is that the values get read like strings, and in fact if I do the console log, the values that are not the min or max appear as strings, and I believe that this is the problem why I get wrong color values.
I tried also to set every d.Weight as a number in the domain, like so:
dataset.forEach(function (d) { d.Weight = +d.Weight; });
But it doesn't work either. Attached here's an image of what I'm getting:
The X Axis is set to the Weight, so the colour of the points should be from lighter to darker going left to right, but it clearly isn't:
Any help is appreciated, thanks!
EDIT Forgot to mention that i tried with scale.linear() but with it I get this result:
Just the first values get picked by the circles
Ordinal scales work differently from linear scales in that no interpolation between domain elements is done. To quote the documentation:
The first element in values will be mapped to the first element in the output range, the second domain value to the second range value, and so on.
This means that your input values are being mapped incorrectly, as you're only using min and max to set up the domain. For your purposes, you probably want a linear scale.
When using a linear scale, you'll have to tell D3 how to interpolate the values of the output range, e.g.
.range(["#D6F5D6", "#ADEBAD", "#84E184", "#5BD75B","#32CD32"])
.interpolate(d3.interpolateRgb);
Note that in this case, you also need to provide the same number of input values as output values:
Although linear scales typically have just two numeric values in their domain, you can specify more than two values for a polylinear scale. In this case, there must be an equivalent number of values in the output range.
In your case, it would be easiest to simply take the min and max and the two extreme colours.
I have an ssrs report where I have many pie charts with the fields pass and fail as well as up to 3 other miscellaneous fields and I wish to be able to color the pass always green and the fail always red but the other fields could be a default value. Is this even possible to do? I have seen code examples with code for custom color in pie charts but I have no clue how to do this and have not found where I would put my custom code. What im trying to do is slightly different from what all those other examples do whith only defining a few fields.
=Switch
(
Fields!ResultTypeDescription.Value = "Pass", "Green",
Fields!ResultTypeDescription.Value = "Fail", "Red",
Fields!ResultTypeDescription.Value = "Assigned To Machine", "Blue",
Fields!ResultTypeDescription.Value = "Not Yet Assigned", "Orange",
True , "Gray"
)
In order to get our dynamic coloring working,i overrode the colors from the palette. This is how it’s done. Right-click on the pie and select Series Properties. Select the Fill page and click the Expression (fx) button to define the color.