Skip to content

Commit

Permalink
Merge pull request #297 from vertica/bugfix_qprof_ui
Browse files Browse the repository at this point in the history
Bugfix - When Query Events has no value for a category
  • Loading branch information
oualib authored Oct 19, 2024
2 parents 40bd0e4 + 58eb53e commit 62a81e3
Showing 1 changed file with 16 additions and 15 deletions.
31 changes: 16 additions & 15 deletions project/ui/qprof-ui.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -1308,24 +1308,25 @@
"\n",
"def create_pie_chart(title,values):\n",
" total = sum(values)\n",
" \n",
" # Avoid division by zero if total is 0\n",
" if total == 0:\n",
" raise ValueError(\"The sum of the numbers cannot be 0.\")\n",
" \n",
" # Calculate percentages\n",
" percentage1 = (values[0] / total) * 100\n",
" percentage2 = (values[1] / total) * 100\n",
" percentage3 = (values[2] / total) * 100\n",
"\n",
" if total!=0:\n",
" percentage1 = (values[0] / total) * 100 \n",
" percentage2 = (values[1] / total) * 100 \n",
" percentage3 = (values[2] / total) * 100\n",
" labels = ['Low', 'Medium', 'High']\n",
" color_sequence = ['green', 'orange', 'red']\n",
" else:\n",
" values = [0]\n",
" percentage1 = 100\n",
" percentage2 = percentage3 = 0\n",
" labels = ['No Value']\n",
" color_sequence = ['grey']\n",
" percentages = [percentage1, percentage2, percentage3]\n",
" labels = ['Low', 'Medium', 'High']\n",
" color_sequence = ['green', 'orange', 'red']\n",
" \n",
" # Calculate the cumulative sum and angles\n",
" cumsum = np.cumsum(percentages)\n",
" total_percentage = sum(percentages)\n",
" angles = (cumsum / total_percentage) * 180\n",
" angles = (cumsum / total_percentage) * 180 \n",
"\n",
" \n",
" # Create the arch chart\n",
" fig = go.Figure()\n",
Expand All @@ -1345,7 +1346,7 @@
" # textinfo=\"text\", # Use textinfo instead of textposition\n",
" hoverinfo=\"text\"\n",
" ))\n",
" \n",
" \n",
" # Customize the layout\n",
" fig.update_layout(\n",
" title=dict(\n",
Expand Down Expand Up @@ -1821,7 +1822,7 @@
"</head>\n",
"<body>\n",
" <div class=\"version\">\n",
" Page version update date: 9/30/2024\n",
" Page version update date: 10/18/2024\n",
" </div>\n",
"</body>\n",
"</html>"
Expand Down

0 comments on commit 62a81e3

Please sign in to comment.