Custom Chart Fill / Pattern - charts

I am struggling to define the fill color and fill pattern of a stacked column chart. To clarify, I have one series value, and two series groupings (RepairLevel, InProcess).
In the fill color expression I have:
=Switch( Fields!RepairLevel.Value = "Major", "red"
,Fields!RepairLevel.Value = "Mid", "orange"
,Fields!RepairLevel.Value = "Minor", "yellow"
,Fields!RepairLevel.Value = "NA", "grey"
,Fields!RepairLevel.Value = "Unspecified", "light grey" )
In the fill pattern expression I have entered:
=Switch( Fields!InProcess.Value = True, "BackwardDiagonal"
,Fields!InProcess.Value = False, "None" )
It seems that the fill color is working properly. However, the fill pattern is not -- I am getting various fill patterns. Thanks in advance for any insights, I truly appreciate your time.

Related

vscode if/else conditions in user defined snippet

Looking at the vscode documentation for user defined snippets, it would appear that using the regex transform, you can do if/else conditions.
However, I can't seem to find any examples of this and I'm struggling to understand the correct syntax based on the BNF alone.
Can someone explain the syntax for this?
For example,
Lets say I have a snippet like this:
"body": [
"let color = '${1|white,black|}';",
"let hex = '${???}';"
]
If color==white, I want hex to output #fff, otherwise if black #000.
This works:
"color conditional": {
"prefix": "_hex",
"body": [
"let color = '${1};",
"let hex = '${1/(white)|(black)|(red)/${1:+#fff}${2:+#000}${3:+#f00}/}';" //works
],
"description": "conditional color"
},
However, as soon as I try it with default placeholders and choices, like
"let color = '${1|white,black|}';", // does not work
Apparently, you cannot do snippet transforms on default placeholder values. See transforms on placeholder values issues
I used the simpler if transform style, so here:
${1/(white)|(black)|(red)/${1:+#fff}${2:+#000}${3:+#f00}
if there is a group 1 $[1} in this case white then replace that group 1 with #fff and if group 2 (black) replace with #000, etc.
You could make it just an if/else (white) or not pretty easily.
"let hex = '${1/(white)/${1:?#fff:#000}/}';" // any non-`white` entry will print `#000`.
${1:? => if group 1 (white) print #fff , else print #000
The vscode docs are not very helpful on these conditional replacements, if you have more questions on their syntax, let me know.

Color in legend doesn't match the color in map

Basically, I tried to use colors to show the value, however, when I add a legend, the color in legend doesn't match the color in the map.
output$map <- renderLeaflet({
temp<-data[data$coralType==input$type,]
temp<- aggregate(temp,by=list(temp$location),FUN=mean)
#print(temp)
qpal <- colorQuantile("YlOrRd", temp$value,n=6)
leaflet(temp) %>% addProviderTiles("Esri.WorldImagery") %>%
addCircleMarkers(~longitude,~latitude,radius
=~value*35,color=~qpal(value),
label=paste(paste(temp$Group.1,":"),temp$value),fillOpacity
=0.8) %>%
addLegend("topright", pal = qpal, values = ~value,
title = "Average Rate", opacity = 1)
})
Not sure if this helps, but shortly before you posted this question, a similar question appeared on git: https://github.com/r-spatial/mapview/issues/219
I'm having a similar issue but with legends that use nominal data (not ramped gradients).

How to extract the name of the type of color that was just randomly generated

I would like to generate a random color and then extract the name of the color. I know that I can generate the color by creating three randomized floats and then returning a UIColor, but I am lost when it comes time to define the name of the color that has just been created.
It is totally possible! Here's very basic solution for Swift 3:
To pre-define colours go to http://colorizer.org and use the HSV/HSB sliders for each colour wanted. Start from left to define the ranges for each slider. It's a bit of work, but we need those values. Notice the ranges:
Hue = 0-360
Sat = 0-100
Br = 0-100
After we have the values of each colour range, we need to convert the HUE values for Swift use by dividing it by 360. Saturation & Brightness values needs to be divided by 100.
For instance, if I want to define blue colour, the measures from the website I took are
H = 179...240
S = 50...100
B = 60...100
H = H/360
S = S/100
B = B/100
H range = 0.497...0.667
S range = 0.5...1.0
B range = 0.6...1.0
I have pre-defined few basic colours in spreadsheet:
Now we need to implement in the code. Create function as such:
func whichColor(color: UIColor) -> String{
var (h,s,b,a) : (CGFloat, CGFloat, CGFloat, CGFloat) = (0,0,0,0)
_ = color.getHue(&h, saturation: &s, brightness: &b, alpha: &a)
print("HSB range- h: \(h), s: \(s), v: \(b)")
var colorTitle = ""
switch (h, s, b) {
// red
case (0...0.138, 0.88...1.00, 0.75...1.00):
colorTitle = "red"
// yellow
case (0.139...0.175, 0.30...1.00, 0.80...1.00):
colorTitle = "yellow"
// green
case (0.176...0.422, 0.30...1.00, 0.60...1.00):
colorTitle = "green"
// teal
case (0.423...0.494, 0.30...1.00, 0.54...1.00):
colorTitle = "teal"
// blue
case (0.495...0.667, 0.30...1.00, 0.60...1.00):
colorTitle = "blue"
// purple
case (0.668...0.792, 0.30...1.00, 0.40...1.00):
colorTitle = "purple"
// pink
case (0.793...0.977, 0.30...1.00, 0.80...1.00):
colorTitle = "pink"
// brown
case (0...0.097, 0.50...1.00, 0.25...0.58):
colorTitle = "brown"
// white
case (0...1.00, 0...0.05, 0.95...1.00):
colorTitle = "white"
// grey
case (0...1.00, 0, 0.25...0.94):
colorTitle = "grey"
// black
case (0...1.00, 0...1.00, 0...0.07):
colorTitle = "black"
default:
print("empty def")
colorTitle = "Color didn't fit defined ranges..."
}
return colorTitle
}
And now just pass the colour you want to analyse and it should print generic name of the colour:
print("Color: \(self.whichColor(color: YourColorSource!))")
It is not perfect, whoever wants to use it, needs to play with the ranges properly to define the real borders between colours or implementing more colours.
Note: Some values from the spreadsheet are not matching the Swift code as I have adjusted it for continuous range of colours without gaps...
Another option would be to define a set of ranges for Red, Blue, and Green. Based on where the color RGB values fall into their respective set of ranges, it will return some approximate color name.
For example, if Red, Green, and Blue are all close to 255, you append "Light" to the front of the color name (as in "Light Green")
I also found this library which accepts enum values for its random color initializers. You could probably adapt those enums to also return corresponding string values, forming a color name dynamically.
I don't think that's really possible. You can, however, create your own NSDictionary of UIColors (where the key would be the name you give the color) and then randomly select one from the dictionary.
Once you have generated random color, get the rgb values. Use this link to define color names for appropriate rgb values and generate names.It certainly doesn't cover all the colors but its one of those possible solutions.

Assign a color to individual row numbers

I am trying to assign an individual color to each row in a group. There are approximately 50 rows I need to assign a color and they all must be unique. What would be the easiest way to do this?
I do not want to do the alternating row colors:
"=IIf(RowNumber("DataSet1") Mod 2 = 1, "White","Blue")",
but if there was a way to modify this expression to do 50 colors and then repeat I'd be okay with that.
you can use choose . otherwise use custom code function
=Choose(ROWNUMBER(nothing) mod 50, "Brown", "Blue", "GoldenRod", "Olive", "MediumTurquoise","Red", "Green", "DeepSkyBlue", "Yellow", "Chocolate", "Purple", "DarkOrange" ,.....)

Indicators in SSRS

I have a column in SSRS report. The value is "True" or "False" or "Yes" or "No" or "1" or "0"
Instead of showing that in that column, I would like to use indicator.
I placed indicator in that column but need to set start and end property. How do I go about doing it so I can show green checkmark when it's "True", "Yes", or '1" and red otherwise?
I am trying =IFF(Fields!Column_name.Value = "True", "Red", "Green") for the Start value for Green Check mark...but obviously I am wrong...
any help?
Well maybe its just a typo in your question but a couple things stand out
the function is IIF, not IFF
The True result should come first after the condition
I've never used the indicators before, but looking briefly at them, it looks like you can define ranges that are acceptable (green), unacceptable(red), or in the middle (yellow).
Start and End should probably be numeric values, "Green" and "Red" don't seem like valid values.
Try binding the indicator value expression to something like this.
=IIF(Fields!ColumnName.Value = "True" OrElse
Fields!ColumnName.Value = "Yes" OrElse
Fields!ColumnName.Value = "1", 100, 0)
Go to the Indicators properties > Values And States and put the Check's Start & End Value to 1. And the X put it's Start & End Value to 0.
Then write your expression like this:
=iif(First(Fields!YourField.Value, "YourDataSet")=True,1,0)
That should give you a Check if checked or an X if not.