Is it possible to add quantitative values to color legend in Vegalite? - vega-lite

I'm currently trying to create a donut chart in Vega-lite that uses Royalty as theta and Year as color, and includes both values in the legend. The legend for color is working fine, but I cannot figure out how to either concatenate the theta values, or create a new legend.
I've tried hiding another arc underneath the current one and using Royalty as color, but Vega-lite connects the legends so you cannot control them individually.
I've tried creating a new text mark and moving it next to the legend, but the values stack as there is no x or y values. This way also feels wrong. I've gone over the documentation multiple times and I can't seem to find a solution.
Is there a way to do this?
vega-editor

Just concatenate the values in the Year field.
{"Year": "2022 - 100000", "Royalty": 100000},
{"Year": "2021 - 150000", "Royalty": 150000},
{"Year": "2020 - 200000", "Royalty": 200000}
You could also create the label in DAX and pass it in as a separate column.
{"Year": "2022", "Year label": "2022 - 100000", "Royalty": 100000},
{"Year": "2021", "Year label": "2021 - 150000", "Royalty": 150000},
{"Year": "2020", "Year label": "2020 - 200000", "Royalty": 200000}
Open the Chart in the Vega Editor

Related

SSRS - Using iff(Instr(Fields! to find certain text in a string

I'm struggling (spending LOTS of time trying to figure this out) to make an iff statement work in SSRS/Report Builder.
I'm pulling a VARCHAR into a report. In the VARCHAR, consists of lots of words/text.
I'm trying to colour this textbox if this VARCHAR string contains the word "red" or "amber" or "green".
If it does find either of these words in the VARCHAR string, I would like it to colour the textbox the same colour as the text it's looking for.
If it finds "red" in the VARCHAR, the textbox becomes red in colour, etc.
I've looked on google and youtube lots and have found two potential solutions:
iff(Fields!note.value.contains("red"), "red", "white")
-Above I believe should look for "red" in the VARCHAR string and then fill the textbox red if it matches or white if no match?
iff(InStr()<0, [true], [false])
The second option I have no idea how this would work. I apologise that my syntax for vba is awful. Any help would be GREATLY appreciated. I'm trying to learn SSRS and/or Report Builder on the job.
Please note I'm using Report Builder ver 15 OR Visual Studio 2019.
Kind regards.
You should be able to use Tostring.Contains() like this... (I've used SWITCH rather than nested IIFs as it's cleaner in my opinion.
=SWITCH(
Fields!AddressLine1.Value.ToString.Contains("Street"), "Red",
Fields!AddressLine1.Value.ToString.Contains("Road"), "Green",
Fields!AddressLine1.Value.ToString.Contains("Ave"), "Orange",
True, Nothing)
The last True acts like an else. I've also used Nothing which is the default 'transparent'
I used this on a test dataset and applied the expression to the last column, here are the results....

(Sharepoint JSON) Is it possible to change icons for a sharepoint list column based on checkboxes?

I have a list where I am trying to keep track of new parts for our company, and I want to set a progress bar to track how each item is progressing as it is introduced to the company. However, my boss wants to use checkboxes to mark certain stages as complete, so I was wondering if there is a way to set the JSON format script to select the correct progress bar icon depending on which or how many checkboxes are filled in. there are four checkboxes with the following names: CompareDrawingstoBOM, NewPartisScheduled, MaterialSecuredinNPL, ProgrammingComplete. I'm not really familiar with JSON at all so any help with this would be appreciated.
This is the basic JSON introduction that you could reference:
Site template JSON schema
Use column formatting to customize SharePoint
Try using below JSON code on your choice field:
{
"$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
"elmType": "div",
"txtContent": "=join(#currentField, '\n')"
}
How join() works:
join() takes 2 operands. The first is an array (multi-select person or choice field) and the second is the separating string.
Returns a string concatenation of the array values separated by the separating string.
Example for multi-select choice field:
"txtContent": "=join(#currentField, ', ')" --> This will result in Apple, Orange, Cherry (depending on the selected values)
Example for multi-select person field:
"txtContent": "=join(#currentField.title, '|')" --> This will result in Chris Kent|Vesa Juvonen|Jeff Teper (depending on the selected persons names).

SSRS column background color formatting not working

I have the following requirement:
A column has negative values and NA values as well. The negative and NA value cells should be "Red" and other cells should be "light grey". I have written the following expression for this:
=IIF(Fields!BaseDOS.Value ="NA" OR Fields!BaseDOS.Value < 0, "Red", "LightGrey")
But it is not working for NA fields. Also I am using expression to show the negative values in parentheses:
=Format(Fields!BaseDOS.Value,"##0.00;(##0.00)")
This is also not working. Please help.
You should really post each problem as a separate question.
In the background color property for the text box try:
=IIF(Fields!BaseDOS.Value ="NA" OR Fields!BaseDOS.Value < "0", "Red", "LightGrey")
BaseDos must be a string.
In the format property for the textbox you want to show parenthesis try:
#,##0.00;(#,##0.00)

Octave: How to create a legend for grouped bar graphs?

I'm using Octaves "bar" command to plot a grouped bar graph based on data loded from a matrix stored in an external file. A similar plot based on random data can be created using this command:
bar(rand(4, 6));
I'd like to create a legend explaning the 6 bar colors occurring in each group instead of a legend for the 4 bar groups themselves. Executing the command
legend({"Probe 1", "Probe 2", "Probe 3", "Probe 4", "Probe 5", "Probe 6"});
creates the legend labels but does not assign the bar colors. Is there a way to fix this?
According to the Octave legend documentation, specifically examples 18 and 19, you should get what you are looking for with either legend('Probe 1', 'Probe 2', ...); or with legend({'Probe 1', 'Probe 2', ...});. Maybe try changing your quotations to single-quotes.
You can also get a handle to your bar graph with:
b = bar(rand(4, 6));
And then plot the legend with color boxes with:
legend(b, 'probe 1', 'probe 2', ...);
Edit: I tested each of the above methods and they all produced the legend that I believe you are looking for. The result looked slightly different than the figure here (made with MATLAB), but functionally the same. Oddly enough, so did your syntax (with double quotes instead of single). Are you plotting the figure in X11? Or are you plotting anything on top of the bar chart before generating the legend? Passing the handle to the bar chart should solve the latter case.

Color chart bars depending on category group value

I have the following chart (ssrs 2008), it shows sales according to #FromDate and #ToDate parameters.
The data is correct.
The problem is that when it shows comparison between years (=more than one year for the same month on a chart), the color stays the same, as you can see in months 4, 5, 6, 7:
How can i change it?
I would appreciate your help
There are a few different web descriptions with overviews of controlling the bar colors in a chart, such as this at learn.microsoft.com or Change the series colors for a bar chart (Images are currently dead in this, limiting its helpfulness).
The key is finding the "Series Properties" dialog and the "Fill" section, where you can specify the fill color: Use an expression such as:
=IIF(YEAR(Fields!MyDateField.Value) mod 2 = 0, "#FF0000", "#00FF00")
To Add some more explanation to JamieFs answer. This is the steps that I followed:
Right click on the series Select "Series Properites..."
Go to Fill:
Press the Expression button(Fx) and type in your equation to calculate the colour: