Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

If you need to introduce a quick visual evaluation of your data, such as in a Top/Bottom Performers table, you can make use of the traffic lights (green, yellow, red) in the data tables. In the calculation logic, you define the conditions corresponding to each color (see the example below).  

...

The following images are ready to use:

Code Block
resultMatrix.imageCelllibraryImage("/images/small_trafficlight_1_green.pngTraffic","green")
resultMatrix.imageCelllibraryImage("/images/small_trafficlight_2_yellow.pngTraffic","yellow")
resultMatrix.imageCelllibraryImage("/images/small_trafficlight_3_red.png"Traffic","red")


Code Block
def rawMatrix = api.datamartLookup("CustTX","CustomerName","CustomerID","NetMargin%-")

def resultMatrix = api.newMatrix("Margin Status","Customer Id","Name","Net Margin %")
if(rawMatrix == null) return 0

def i=0
for(entry in rawMatrix.getEntries()) {
  def row =[:]
  row.put("Customer Id",resultMatrix.linkCell(entry.get("CustomerID"),"customersPage",entry.get("CustomerID")))
  row.put("Name",entry.get("CustomerName"))
  def margin = entry.get("NetMargin%")/100
  row.put("Net Margin %",resultMatrix.styledCell(margin,"#006300",null,"bold"))
  if(margin <= 0) row.put("Margin Status",resultMatrix.imageCelllibraryImage("/images/small_trafficlight_3_red.png"Traffic","red"))
  if(margin <0.1 && margin > 0) row.put("Margin Status",resultMatrix.imageCelllibraryImage("/images/small_trafficlight_2_yellow.pngTraffic","yellow"))
  if(margin >=0.1 ) row.put("Margin Status",resultMatrix.imageCelllibraryImage("/images/small_trafficlight_1_green.png"Traffic","green"))
  resultMatrix.addRow(row)
  i++
  if(i>10) break;
}
resultMatrix.setColumnFormat("Net Margin %",FieldFormatType.PERCENT)
return resultMatrix

...