Visualizations Bar Fight
Node start index
BarFight allows you to scroll up and down the number of bars, and set a starting point.
Sample data
Let's import PlotAPI and load our sample data.
from plotapi import BarFight
samples = [
{"order": 0, "name": "Sankey", "value": 10},
{"order": 0, "name": "Terminus", "value": 12},
{"order": 0, "name": "Chord", "value": 8},
{"order": 0, "name": "Bar Fight", "value": 9},
{"order": 0, "name": "Pie Fight", "value": 12},
{"order": 1, "name": "Sankey", "value": 18},
{"order": 1, "name": "Terminus", "value": 24},
{"order": 1, "name": "Chord", "value": 22},
{"order": 1, "name": "Bar Fight", "value": 14},
{"order": 1, "name": "Pie Fight", "value": 17},
{"order": 2, "name": "Sankey", "value": 24},
{"order": 2, "name": "Terminus", "value": 40},
{"order": 2, "name": "Chord", "value": 32},
{"order": 2, "name": "Bar Fight", "value": 19},
{"order": 2, "name": "Pie Fight", "value": 42},
{"order": 3, "name": "Sankey", "value": 32},
{"order": 3, "name": "Terminus", "value": 62},
{"order": 3, "name": "Chord", "value": 40},
{"order": 3, "name": "Bar Fight", "value": 25},
{"order": 3, "name": "Pie Fight", "value": 64},
{"order": 4, "name": "Sankey", "value": 32},
{"order": 4, "name": "Terminus", "value": 75},
{"order": 4, "name": "Chord", "value": 55},
{"order": 4, "name": "Bar Fight", "value": 45},
{"order": 4, "name": "Pie Fight", "value": 120},
]
Demonstration
By default PlotAPI displays the winning bar at the top. However, if you'd prefer to show a different bar at the top, you can use the start_idx
parameter.
Let's demonstrate setting this to 1
, with the top_n
also set to 3
. This will show us 3 bars, with the bar in second place (with zero-indexing, 1 is the second position) positioned at the top.
This window can be scrolled up and down with the arrows in the top-right. The window size can also be increased or decreased with the plus and minus buttons.
BarFight(samples, start_idx=1, top_n=3).show()