How to vary background color based on value - html

I'm listing out a table that has the results of a tournament. I have the final placements, as well as the original seeds for each team in the tournament. I'm adding a small bubble with a +/- of how the final placement compares to the original seeding. I'd like to make the background get a darker red as the team did worse, and darker green as the team did better.
Example:
Team A finished 1st and was seeded 3rd -> light green
Team B finish 2nd and was seeded 30th -> dark green
Team C finished 10th was seeded 8th -> light red
Team D finish 30th and was seeded 1st -> dark red
I'd like to set a limit obviously for how dark/light the colors get, so teams that out/under performed past a certain amount would all have the same dark tone.
My site is built using Angular, but is this possible to do with just some simple CSS?
Here is a picture from another site that has this already implemented:
As you can see, the final finish is listed on the left, and how well they performed in comparison to their original seeding is on the right. Blank signifies Seed == Finish

You can create an array for the colors
TS:
colors = [{ finished: "1st", color: "light green" }, { finished: "30th", color: "dark green"}]
Loop through your data in a table (or how you prefer) and add ngStyle:
<table>
<th>Team</th>
<th>Finished</th>
<tr *ngFor="let res of colors" [ngStyle]="{'background':getColor(res.finished)}">
<td>res.whateveryourfieldiscalled</td>
<td>res.whateveryourfieldiscalled</td>
</tr>
</table>
And then add it with a ts getColor method:
getColor(finished) {
return this.colors.filter(item => item.finished === finished)[0].color
}

Related

MS Access - Conditional Formatting in Continuous Form on Specific Cells

I'm working on Access and I have a question to ask on conditional formatting. As you can see in the picture I have 2 columns of data, L/I and Unit Price.
What I want to do is whenever there is duplicated L/I appearing in the data, conditional formatting will
highlight the duplicated L/I, and
compare on only the specific unit prices with duplicated L/I and show the cheaper price with green
font colour, yellow for price in the middle and red for the most expensive price.
I have done the first part as shown in the picture but I am clueless on the expression to be used for the second part. Not sure if I have articulated my concerns accurately but thanks in advance for attending to this question. Your help is sincerely appreciated.
What my continuous form looks like:
Maybe you could set the record source of the form to a query like beneath that generates a 'helper'-column with the name Indicator that is filled with the text "RED", "YELLOW" or "GREEN" according to their unit price characteristic. Based on this column, inside the form you could use conditional formatting to actually show the unit price in the wanted color. Hope this query helps (you in the right direction). I assumed the table is called "Items", you should change that to your naming.
SELECT i.ID, i.LI, i.UnitPrice, iif(i.UnitPrice = (SELECT MAX(il.UnitPrice) FROM Items AS il WHERE il.LI = i.LI), "RED", iif(i.UnitPrice = (SELECT MIN(il.UnitPrice) FROM Items AS il WHERE il.LI = i.LI), "GREEN", "YELLOW" )) AS Indicator FROM Items as i;

Cesium: Is it possible to make the trailing path thinner?

I'm using the Cesium library to simulate the satellite motion. This code is used to show the path:
path:{
leadTime:data.data_list[0].period/2,
trailTime:data.data_list[0].period/2,
width:1.5,
material: color
}
Is there a way to make the trailing path thinner?
As an example, the SpaceX video: http://youtu.be/rQEqKZ7CJlk?t=47m40s
Couple of comments here. First, with a width of only 1.5, altering the width is likely not the effect you want. Try using a solid color vs a faded color, such as by changing the alpha value. This should be more similar to what you're seeing in that video link.
But, currently Cesium does not support separate path materials for lead and trail times. If you really need both lead and trail paths shown with different colors/widths/etc, you have to insert a duplicate entity in your CZML (whose position can just be a reference to the primary entity position), such that one entity can have only a leadtime and the other has only a trailtime, and they use different path materials.
But if you have a satellite in a stable orbit, you there's a different approach you can take, because the thing keeps circling around the same path. You can use the StripeMaterial to make the orbit line fade from one side to the other.
Here's a live demo that loads simple.czml and replaces the Molniya's yellow orbit with a faded line. The solid part is the most recent trail of the satellite, and the faded part is much further back but serves to show where the satellite is headed next.
Cesium.Camera.DEFAULT_VIEW_FACTOR = 5.5;
var viewer = new Cesium.Viewer('cesiumContainer', {
shouldAnimate : true
});
Cesium.CzmlDataSource.load('../../../../Apps/SampleData/simple.czml').then(function(dataSource) {
viewer.dataSources.add(dataSource);
viewer.camera.flyHome(0);
viewer.clock.multiplier = 1800;
var entity = dataSource.entities.getById('Satellite/Molniya_1-92');
var fadedLine = new Cesium.StripeMaterialProperty({
// The newest part of the line is bright yellow.
evenColor: Cesium.Color.YELLOW,
// The oldest part of the line is yellow with a low alpha value.
oddColor: Cesium.Color.YELLOW.withAlpha(0.2),
repeat: 1,
offset: 0.25,
orientation: Cesium.StripeOrientation.VERTICAL
});
entity.path.material = fadedLine;
entity.path.leadTime = new Cesium.ConstantProperty(0);
entity.path.trailTime = new Cesium.ConstantProperty(3600 * 12);
});
Here you can play with the color, of course, but I would recommend keeping the same base color for even and odd. The withAlpha value of 0.2 on the oddColor here controls how faded the line gets, range is 0 to 1. The offsetvalue here can also be tweaked, to control the placement of the fade range. leadTime should be zero, and trailTime should be the orbit's period.

space is not showing in html

I don't know whether it is a basic question, but I need to ask.
Here is my problem. when a wrote a simple HTML code for showing a paragraph,
but its not getting in the correct format that i wish.
I am adding code below.
<p>
Eosinophil count - absolute
An absolute eosinophil count is a blood test that measures the number of white blood cells called eosinophils.
Eosinophils become active when you have certain allergic diseases, infections, and other medical conditions.
How the Test is Performed
Most of the time blood is drawn from a vein on the inside of the elbow or the back of the hand. The site is cleaned with an antiseptic.
The health care provider wraps an elastic band around your upper arm to make the vein swell with blood.
Next, the provider gently inserts a needle into the vein. The blood collects into an airtight tube attached to the needle.
The elastic band is removed from your arm. The needle is then removed and the site is covered to stop bleeding.
Things to Know
In infants or young children, a sharp tool called a lancet may be used to prick the skin.
The blood collects in a small glass tube, or onto a slide or test strip. A bandage is put on the spot to stop bleeding.
Reference Range
The serum reference ranges of eosinophils are as follows:
Eosinophils blood (%): 0.0-6.0 (This range may vary slightly in different laboratories.)
Eosinophil blood count (absolute): 30-350. The percentage of eosinophils is multiplied by the white blood cell count to
give the absolute eosinophil count. This range may vary slightly in different laboratories.
ANTIGEN SUSPENSION SERUM DILUTION
. 1:30 1:60 1:120 1:240
--------------------------------------------------------------------------------
Salmonella Typhi "O" : -- -- -- --
Salmonella Typhi "H" : -- -- -- --
Salmonella Para Typhi "AH" : -- -- -- --
Salmonella Para Typhi "BH" : -- -- -- --
</p>
But in output all the spaces are truncated.
How to get the exact text as output?
Check white-space: pre; property in css here
p {
white-space: pre;
}
<p>
Eosinophil count - absolute
An absolute eosinophil count is a blood test that measures the number of white blood cells called eosinophils.
Eosinophils become active when you have certain allergic diseases, infections, and other medical conditions.
How the Test is Performed
Most of the time blood is drawn from a vein on the inside of the elbow or the back of the hand. The site is cleaned with an antiseptic.
The health care provider wraps an elastic band around your upper arm to make the vein swell with blood.
Next, the provider gently inserts a needle into the vein. The blood collects into an airtight tube attached to the needle.
The elastic band is removed from your arm. The needle is then removed and the site is covered to stop bleeding.
Things to Know
In infants or young children, a sharp tool called a lancet may be used to prick the skin.
The blood collects in a small glass tube, or onto a slide or test strip. A bandage is put on the spot to stop bleeding.
Reference Range
The serum reference ranges of eosinophils are as follows:
Eosinophils blood (%): 0.0-6.0 (This range may vary slightly in different laboratories.)
Eosinophil blood count (absolute): 30-350. The percentage of eosinophils is multiplied by the white blood cell count to
give the absolute eosinophil count. This range may vary slightly in different laboratories.
ANTIGEN SUSPENSION SERUM DILUTION
. 1:30 1:60 1:120 1:240
--------------------------------------------------------------------------------
Salmonella Typhi "O" : -- -- -- --
Salmonella Typhi "H" : -- -- -- --
Salmonella Para Typhi "AH" : -- -- -- --
Salmonella Para Typhi "BH" : -- -- -- --
</p>
use &nbsp for space in HTML
In HTML, multiple spaces are automatically replaced by only one space except if your text is surrounded with <pre> tag.
If you want your spaces in another type of tag (e.g. <p>) you need to use HTML entities. The HTML entity for a normal space is and for a tab character it's &tab;. There's a lot of HTML entities like those. Here is a good reference to find the HTML entities you need: HTML entities reference chart

How can I prevent redundant values from being displayed in a column in an SSRS report?

I have the Textbox in the data row set up in the usual way, with an expression like so:
=Fields!Description.Value
The data is being extracted and displayed fine, in fact too well for my tastes, as the Description is repeated N times; I want only the first unique value to display, and for it to be invisible after that until the Description changes. IOW, if it starts off with "Green Bay Packers" 80 times, I only want the first one to display that value, and the Description to not be visible again until its value changes to "Minnesota Vikings" (or whatever).
IOW, I want it to look like this:
Green Bay Packers Aaron Rodgers
Clay Matthews
Julius Peppers
Eddie Lacey
...not like this:
Green Bay Packers Aaron Rodgers
Green Bay Packers Clay Matthews
Green Bay Packers Julius Peppers
Green Bay Packers Eddie Lacey
The TextBox does have a "HideDuplicates" property, but the accepted values are not the expected (by me) true and false; they are, instead, the following:
None
CPSData (the name of the data set the report uses)
Details
I can't see how choosing any of these would help me.
How can I effectively set "HideDuplicates" (or the appropriate property) to false?
The HideDuplicates property is the way to do this. The options in the list are the scopes that are applicable within that section of the report. Choose one, and run the report in preview mode to see the results. If the results are not what you expect, try another option. It isn't terribly intuitive how it works, but it does work for me.

SSRS chart lines not connecting

I have an SSRS Line chart which plots supply points with square feet on the X axis and Price on the Y axis. Right now I don't really care about making it pretty just getting the lines to show up correctly. I am plotting the points and grouping by Subdivision/Builder.
So for example Subdivision A has builders Y and Z. I want to show different colors and lines for Subdivision A builder Y verses Subdivision A Builder Z.
The problem is that the lines are not connecting when a point for another subdivision builder combination breaks up that line.
The grey line and points below are not all connected as the yellow point is between the grey points so the grey line is not connected to all grey points.
How can I make the points of the same color (same Subdivision/Builder) connected via a line?
As I found out the hard way recently, this problem is often caused by null values in the data not being properly handled by SSRS. Without seeing your data, I can't be certain that's the cause, but nulls were the culprit I encountered the same behavior.
The solutions usually involve assigning values to the color of the EmptyPoint property on the Series, sometimes in conjunction with setting the EmptyPointValue to specify null handling. I've found many references to this problem on the web, but I'll only post links to the best two, both of which are on StackExchange:
The thread SSRS Line Chart NULL VALUE - Horizontal Line contains a thorough discussion of this issue. The usual workaround given is to hard-code a color expression for each line using an IIf, but sometimes this isn't an option, especially if the field you're grouping on has dynamic, unpredictable values, as my dataset did.
The picture posted there depicts clear examples of the same type of line breaks. The user named trubs posted a code sample which illustrates how to set the EmptyPoint, in case where an Iif will work:
=iif(isNothing(Fields!SelectedValue.Value),'No Color',"LightBlue")
The first reply in SSRS Line Chart Not Connecting Data Points details a workaround for cases when the EmptyPoint value & nulls are the root cause and simple hard-coded IIfs won't do the trick. Although I have yet to get my line colors to match the point markers the way I'd like, I can verify that this solution at least gives you your lines back and allows you to assign a variety of colors to them. It's fairly simple and involves merely pasting in some VB code for a couple color properties.
I was asked in the comments section to provide the details of the solutions, but don't want to plagiarize, so I'll simply do a long direct quote of JohnBob's answer:
Firstly, in order to get the lines to join up, you need to set the
EmptyPoint colour for the series.
Select your series in your chart In the properties tab (not the
dialog) drill down into the EmptyPoint property and set the colour to
be Black
This will get them joining up - yay! But part of the line is colour
and the other part is black, right? That's a bit silly, especially
considering if you leave the colour to Automatic on the EmptyPoint
that it will be transparent.
So, then we need to get the series and the EmptyPoint's colours in
sync. Using code from here. I added some code to the code of the
report.
1). Right click on an empty space on the report and select "Report
Properties" 2). In the code tab, paste the following:
Private colorPalette As String() = {"#418CF0", "#FCB441", "#E0400A", "#05642E", "#1A3B69", "#BFBFBF", "#E0400A", "#FCB441", "DarkBlue", "Tomato", "Orange", "CornflowerBlue", "Gold", "Red", "Green", "LightBlue", "Lime", "Maroon", "LightSteelBlue", "Tan", "Silver"}
Private count As Integer = 0
Private mapping As New System.Collections.Hashtable()
Public Function GetColor(ByVal groupingValue As String) As String
If mapping.ContainsKey(groupingValue) Then
Return mapping(groupingValue)
End If
Dim c As String = colorPalette(count Mod colorPalette.Length)
count = count + 1
mapping.Add(groupingValue, c)
Return c
End Function
Then we need to call this code when setting the colour of the series
and of the EmptyPoint.
Select your series
In the properties tab paste something the following (replace WhateverTheGroupIsForYourSeries with your series group name):
=Code.GetColor(Fields!*WhateverTheGroupIsForYourSeries*.Value)
Drill down to the color element of the EmptyPoint Series property
Paste the same text as from point two [e.g. =Code.GetColor(Fields!*WhateverTheGroupIsForYourSeries*.Value)]
And voila! You're done! I can't believe how unnecessarily difficult
this is :D
I hope this helps.
Just put your Fields!(YourSeriesGroup).Value in Series Groups to above of
Fields!(YourCategoryGroup).Value in Category Groups, your series group should be in both Series Groups and Category Groups (should be above of your initial category group).
And after that right click horizontal axis and select Horizontal Axis Properties. Set Axis Type to Scalar and click OK.