-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f219626
commit 81d1ea7
Showing
4 changed files
with
48 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
from __future__ import annotations | ||
|
||
from typing import Callable, Dict | ||
|
||
from endstone_bstats._charts.custom_chart import CustomChart | ||
|
||
|
||
class DrilldownPie(CustomChart): | ||
def __init__( | ||
self, chart_id: str, get_values: Callable[[], Dict[str, Dict[str, int]] | None] | ||
) -> None: | ||
""" | ||
Class constructor. | ||
Args: | ||
chart_id (str): The id of the chart. | ||
get_values (Callable[[], Dict[str, Dict[str, int]] | None]): The callable which is used to request the chart data. | ||
""" | ||
|
||
super().__init__(chart_id) | ||
self.get_values = get_values | ||
|
||
def get_chart_data(self) -> dict | None: | ||
""" | ||
Gets the data for the advanced pie chart. | ||
Returns: | ||
dict | None: A dictionary with the chart data. | ||
""" | ||
|
||
values = {} | ||
map_values = self.get_values() | ||
if not map_values: | ||
return None | ||
|
||
for key, value in map_values.items(): | ||
if not value: | ||
continue | ||
values[key] = value | ||
|
||
if not values: | ||
return None | ||
|
||
return {"values": values} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters