Skip to content

Commit

Permalink
feat(chart_sdk_: add test to NumericalBarChart
Browse files Browse the repository at this point in the history
  • Loading branch information
dvalleri committed Dec 9, 2024
1 parent 86b4b03 commit d3a1987
Show file tree
Hide file tree
Showing 4 changed files with 174 additions and 45 deletions.
45 changes: 7 additions & 38 deletions chart_sdk/radicalbit_platform_chart_sdk/charts/chart.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,37 +46,26 @@ def numerical_bar_chart(self, data: NumericalBarChartData) -> EChartsRawWidget:
"right": 20,
"bottom": 0,
"top": 10,
"containLabel": true
"containLabel": True
},
"xAxis": {
"type": "category",
"axisTick": {
"show": false
"show": False
},
"axisLine": {
"show": false
"show": False
},
"splitLine": {
"show": false
"show": False
},
"axisLabel": {
"fontSize": 12,
"interval": 0,
"color": "#9B99A1",
"rotate": 20
},
"data": [
"[19,700-99,400) ",
"[99,400-179,000) ",
"[179,000-259,000) ",
"[259,000-339,000) ",
"[339,000-418,000) ",
"[418,000-498,000) ",
"[498,000-578,000) ",
"[578,000-657,000) ",
"[657,000-737,000) ",
"[737,000-817,000] "
]
"data": data.bucket_data
},
"yAxis": {
"type": "value",
Expand All @@ -91,35 +80,15 @@ def numerical_bar_chart(self, data: NumericalBarChartData) -> EChartsRawWidget:
}
},
"emphasis": {
"disabled": true
"disabled": True
},
"barCategoryGap": "0",
"barGap": "0",
"itemStyle": {
"borderWidth": 1,
"borderColor": "rgba(201, 25, 25, 1)"
},
"series": [
{
"title": "reference",
"type": "bar",
"itemStyle": {
"color": "#9B99A1"
},
"data": [
502,
982,
896,
356,
181,
44,
24,
10,
3,
2
]
}
]
"series": series
}

return EChartsRawWidget(option=option)
3 changes: 2 additions & 1 deletion chart_sdk/radicalbit_platform_chart_sdk/charts/chart_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@ class ChartData(BaseModel):
x_axis_data: List[str]

class NumericalBarChartData(BaseModel):
bucket_data: List[str]
reference_data: List[float]
current_data: Optional[List[float]]
current_data: Optional[List[float]] = None
129 changes: 129 additions & 0 deletions chart_sdk/test/numerical_bar_chart.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"id": "cf17c43b-22b9-4d43-83bf-4bd03d068b7e",
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "b10bdb9783f04f15826934a7d560b4ef",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"EChartsRawWidget(option={'grid': {'left': 0, 'right': 20, 'bottom': 0, 'top': 10, 'containLabel': True}, 'xAxi…"
]
},
"execution_count": 1,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"from radicalbit_platform_chart_sdk.charts import NumericalBarChartData, Chart\n",
"\n",
"Chart().numerical_bar_chart(data=NumericalBarChartData(\n",
" bucket_data=[\"[19,700-99,400) \",\"[99,400-179,000) \",\"[179,000-259,000) \",\"[259,000-339,000) \",\"[339,000-418,000) \",\"[418,000-498,000) \",\"[498,000-578,000) \",\"[578,000-657,000) \",\"[657,000-737,000) \",\"[737,000-817,000] \"],\n",
" reference_data=[502,982,896,356,181,44,24,10,3,2],\n",
"))\n",
" "
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "d85c083f-2ed3-4049-aeec-effe807fc0bf",
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "80a4ca3d166b4063808a4122aec532b9",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"EChartsRawWidget(option={'grid': {'left': 0, 'right': 20, 'bottom': 0, 'top': 10, 'containLabel': True}, 'xAxi…"
]
},
"execution_count": 2,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"from radicalbit_platform_chart_sdk.charts import NumericalBarChartData, Chart\n",
"\n",
"Chart().numerical_bar_chart(data=NumericalBarChartData(\n",
" bucket_data=[\"[19,700-99,400) \",\"[99,400-179,000) \",\"[179,000-259,000) \",\"[259,000-339,000) \",\"[339,000-418,000) \",\"[418,000-498,000) \",\"[498,000-578,000) \",\"[578,000-657,000) \",\"[657,000-737,000) \",\"[737,000-817,000] \"],\n",
" reference_data=[502,982,896,356,181,44,24,10,3,2],\n",
" current_data=[]\n",
"))"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "45ed67a9-1c12-4ae2-a066-eafaa9b06749",
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "a8149dbe179240fdb73d1bf6fbf79f77",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"EChartsRawWidget(option={'grid': {'left': 0, 'right': 20, 'bottom': 0, 'top': 10, 'containLabel': True}, 'xAxi…"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"from radicalbit_platform_chart_sdk.charts import NumericalBarChartData, Chart\n",
"\n",
"Chart().numerical_bar_chart(data=NumericalBarChartData(\n",
" bucket_data=[\"[19,700-99,400) \",\"[99,400-179,000) \",\"[179,000-259,000) \",\"[259,000-339,000) \",\"[339,000-418,000) \",\"[418,000-498,000) \",\"[498,000-578,000) \",\"[578,000-657,000) \",\"[657,000-737,000) \",\"[737,000-817,000] \"],\n",
" reference_data=[502,982,896,356,181,44,24,10,3,2],\n",
" current_data=[502,982,896,356,181,44,24,10,3,2]\n",
"))"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "e0e396df-a75e-49b8-8164-544b23fc126a",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "radicalbit-platform-chart-sdk-ayHfA1Gh-py3.1",
"language": "python",
"name": "radicalbit-platform-chart-sdk-ayhfa1gh-py3.1"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.9"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
Loading

0 comments on commit d3a1987

Please sign in to comment.