-
Notifications
You must be signed in to change notification settings - Fork 370
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Display query results as plots #480
Comments
@eeriksp This sounds like a great feature. You've got a fair point about dependencies - something like this would be best as an optional dependency, like how you can do |
…D` is set to `True`
* #480: Add pie chart * #480: Add line chart * #480 Disable chart rendering unless `EXPLORER_CHARTS_ENABLED` is set to `True` * Update requirements/optional.txt Co-authored-by: Mark Walker <theshow@gmail.com> * Update requirements/optional.txt Co-authored-by: Mark Walker <theshow@gmail.com> * Update explorer/views/utils.py Co-authored-by: Mark Walker <theshow@gmail.com> * Rename chart.py to charts.py * Update docs/features.rst Co-authored-by: Mark Walker <theshow@gmail.com> Co-authored-by: Mark Walker <theshow@gmail.com>
@eeriksp Could you please install this beta build and verify everything is working as expected; |
@marksweb we can close this one right? |
@lawson89 Yeah, we've got charts now so I suppose we can. |
The proposal
It would be really useful to see the query results as a plot/graph, especially if the dataset is a little larger and it is hard to make sense out of a long table.
I would be interested in submitting a pull request for implementing that feature.
What would it look like
Right now the query result display has two tabs: "Preview" and "Pivot". I would propose adding new tabs with various plot types (e.g. pie chart, line chart). These plots would only work if the data table has a compatible format. If the table does not have the required format the tab displays a message explaining the expected format.
I illustrate my idea with examples using pie charts and line charts, however, a larger variety of plot types could be considered in the future.
Pie plot
The pie chart would require exactly two columns in the result table, the first containing labels and the other one containing numeric values.
For example
would be rendered as
Line chart
The line chart would require the first column to contain labels for the x-axis (e.g. dates or years) and one or more numeric columns each representing a line.
For example
would be rendered as
Other chart types can have different table formats. In the future, there might be some more advanced options to choose dynamically what columns to use for plotting, but that seems a little more difficult to implement.
Implementation ideas
I propose to use
matplotlib
to draw the plots.And example of using
matplotlib
with Django can be found here.Problems to consider
The only major issues I see with this new feature would be:
Both concerns can be addressed by introducing a setting (e.g.
EXPLORER_PLOTTING
) for turning this feature off or on according to the project's needs.Code
Just for the record, here is the code used to generate the pie chart and the line chart:
What are your thoughts on that?
The text was updated successfully, but these errors were encountered: