Class: Bars
Represents a bar chart visualization component.
The Bars
class is responsible for rendering a bar chart visualization based on the provided data and configuration.
It handles the creation of the necessary HTML elements, rendering of the bars, and management of user interactions such as
scrolling, searching, and sorting.
Extends
Constructors
Constructor
new Bars(
container
,config?
):Bars
Constructs a new instance of the Bars class, which is responsible for rendering a bar chart visualization.
Parameters
Parameter | Type | Description |
---|---|---|
container | HTMLElement | The HTML element that will contain the bar chart. |
config? | BarsConfigInterface | An optional configuration object that can be used to customize the behavior of the bar chart. |
Returns
Bars
Overrides
DisplayStateManager
.constructor
Accessors
_maxDisplayedItems
Get Signature
get _maxDisplayedItems():
number
Returns
number
Methods
extractConfig()
static
extractConfig(config
,defaultConfig
):DisplayStateConfigInterface
Parameters
Parameter | Type |
---|---|
config | DisplayStateConfigInterface |
defaultConfig | DisplayStateConfigInterface |
Returns
Inherited from
DisplayStateManager
.extractConfig
showState()
showState(
text?
):void
Shows the DisplayState element with the specified text
Parameters
Parameter | Type | Description |
---|---|---|
text? | string | Optional text to display, defaults to noDataMessage |
Returns
void
Inherited from
hideState()
hideState():
void
Hides the DisplayState element
Returns
void
Inherited from
setDisplayStateConfig()
setDisplayStateConfig(
config
):void
Updates the DisplayState configuration
Parameters
Parameter | Type |
---|---|
config | DisplayStateConfigInterface |
Returns
void
Inherited from
DisplayStateManager
.setDisplayStateConfig
getConfig()
getConfig():
BarsConfigInterface
Returns the current configuration of the bars module.
Returns
The current configuration.
setConfig()
setConfig(
config?
):void
Sets the configuration for the bars module.
Parameters
Parameter | Type | Description |
---|---|---|
config? | BarsConfigInterface | The configuration object to set. |
Returns
void
setData()
setData(
values?
):void
Sets the data for the bars module.
Parameters
Parameter | Type | Default value | Description |
---|---|---|---|
values? | any [] | [] | The array of values to set as the data. |
Returns
void
sortByCount()
sortByCount(
ascending?
):void
Sorts the data in the bars module by the count of each item, in ascending or descending order.
Parameters
Parameter | Type | Default value | Description |
---|---|---|---|
ascending? | boolean | false | If true, sorts the data in ascending order by count. Otherwise, sorts in descending order. |
Returns
void
sortAlphabetically()
sortAlphabetically(
ascending?
):void
Sorts the data in the bars module alphabetically by the label of each item, in ascending or descending order.
Parameters
Parameter | Type | Default value | Description |
---|---|---|---|
ascending? | boolean | true | If true, sorts the data in ascending alphabetical order by label. Otherwise, sorts in descending alphabetical order. |
Returns
void
destroy()
destroy():
void
Destroys the bars module by removing event listeners, clearing the container, and resetting internal data structures. This method should be called when the bars module is no longer needed to clean up any resources it has allocated.
Returns
void
Overrides
resetList()
resetList():
void
Returns
void
setSelectedItem()
setSelectedItem(
item?
):void
Sets the currently selected item in the bars module.
Parameters
Parameter | Type | Description |
---|---|---|
item? | BarData | The bar data item to select, or undefined to clear the selection. |
Returns
void
setLoadingState()
setLoadingState():
void
Sets the loading state of the bars module by updating the text content of a fallback div. This method is typically called when data is being loaded asynchronously to provide a visual indication to the user.
Returns
void