I'm using Pygal
(with Python
/ Flask
) relatively successfully in regards to loading data, formatting colors, min/max, etc., but can't figure out how to format a number in Pygal
using dollar signs and commas.
I'm getting 265763.557372895 and instead want $265,763.
This goes for both the pop-up boxes when hovering over a data point, as well as the y-axes.
I've looked through pygal.org's documentation to no avail. Does anyone know how to properly format those numbers?
UPDATE:
I'm not quite ready to mark this question "answered" as I still can't get the separating commas. However, I did find the following native formatting option in pygal. This eliminates trailing decimals (without using Python's int()) and adds a dollar sign:
graph.value_formatter = lambda y: "$%.0f" % y
Change the 0f
to 2f
if you prefer two decimals, etc.