2. Categories & Headers - HafisCZ/sf-tools GitHub Wiki

Categories | Headers | Properties


The Statistics module uses a table environment to display the data.
In this context a category is a 'block of columns' that encompasses one or more 'columns' designated by headers.
We refer to categories, headers and rows as elements.




Categories

Attributes assigned to a category by tags are applied to the headers under it unless overridden locally.

Category with a name

category General
header Level
header Base
header Album
header Mount                    

Category without a name

category
header Level
header Base
header Album
header Mount                    

Left category

For each type of table there's a default leftmost category containing the most relevant identification headers for each case (e.g. Timestamp in Me table)
If you want to show custom headers in that category you must use left category to overwrite the default one:

left category
header Class
header Name

Default Left Category Options

Server: Allows you to hide the Server column or change it's width [Players]

# Hide the column completely 
server off
# Set the width to 50px 
server 50                                                

Name: Allows you to change the width of the Name column [Guild, Players]

# Set the width to 50px 
name 50                                                    



Headers

All headers must be placed within a category! Failing to do so will ignore the headers.

Predefined header (List of available headers)

header Level

Custom header

You can create a column with custom calculated data by setting an expr

header My Level
expr Level

Custom header without a name

If an expr is set you can have a nameless column

header
expr Level

Grouped header

You can create a grouped header from an array. You must specify a length

# Custom grouped header named Stages ( 14 columns )
header Stages as group of 14
expr player.Dungeons.Shadow

# The predefined grouped header Potions (3 columns)
header Potions

It can also be nameless if an expr is set. Mind the double space between header and as!

header   as group of 5
expr player.Dungeons.Extra.Shadow

You can access the index from an expression under group headers by using the keyword index

#this will color differently each column of the group in the example above
expc ['red','orange','gold','green','purple'][index]



Properties

Name

You can use alias to rename a header in case you need to keep its predefined attributes.

# Rename
header Header
alias My Header

Or leave it nameless entirely.

# Remove name of (predefined) header
header Header
alias @empty

Type

You can use the keyword define to create a preset containing several tags.
Then all those tags can be applied at once by extending the definition to an element.
All valid tags in the definition are inherited by the element, but can be overridden locally.

To extend an element you can place the prefix <preset_name>: at the beginning of its line:

# Create a preset called MY_DUMMY
define MY_DUMMY
background green
width 150

# Create another preset
define preset1
alias @empty

# Apply preset to whole category
MY_DUMMY:category My category

# Apply both presets to a header
MY_DUMMY,preset1:header My header

# Apply preset to a show as element
preset1:show Something as 100

Alternatively you can apply the definitions using the extend keyword (useful with conditionals):

define PRESET_FOR_PLAYERS_TAB_ONLY
background green
header My Header
if Players
  extend PRESET_FOR_PLAYERS_TAB_ONLY
endif



⚠️ **GitHub.com Fallback** ⚠️