GSS-Cogs / chart-builder

The Chart Builder is a proof-of-concept app to understand the feasibility of using a CSV file (or SPARQL query) to generate and customise a chart or data visualisation
https://chart-builder-no4vxskx7a-nw.a.run.app
2 stars 0 forks source link

Improve the author's ability to configure axis tick label density and format #140

Closed charlesons closed 2 years ago

charlesons commented 2 years ago

This support request is based on feedback from a content author using Chart Builder to create a line chart for figure 2 in the following article:

https://staging.climate-change.data.gov.uk/articles/measuring-greenhouse-gas-emissions

image.png

The data for the chart are a quarterly time series however the desired X axis tick label density is annual.

The X axis tick labels are currently rendering as YYYY-QX where YYYY is the year and X is the quarter.

The chart we are aiming to replicate is as follows:

image.png

On the original chart above the annual tick labels render as YYYY (but the quarterly data point are still plotted).

A simple workaround is to average the data per year (upstream in CSV or PMD) and then plot the annual averages but we would lose some granularity of the data that way.

This case illustrates the need for more control over the tick label density on the axes, and perhaps also the ability to adjust the label format (e.g. ability to remove the QX at the end of the year label).

Tasks:

charlesons commented 2 years ago

Implementation offers multiple options to the user to customise the axis tick labels:

The new capabilities have been applied to both X and Y axes.

At the top level there are auto and manual modes:

Auto mode

This is the default Plotly behaviour and is what was previously available in Chart Builder. We have added an additional property show n ticks that shows in auto mode . When the user enters a number in this property the chart will show the specified number of ticks on the axis.

Manual mode

Manual mode offers more configuration options for the axis tick labels:

charlesons commented 2 years ago

Screenshots showing the new capability applied against the dataset that highlighted the issue.

Auto mode with show n ticks set to 14

image.png

Manual mode with Tick label max. length set to 4, Tick interval set to 4 and Last tick label set to "2021"

image.png

charlesons commented 2 years ago

Note that in manual mode there is a minor issue in that the hover info label doesn't show the X value where an X value isn't available in the axis tick labels (e.g. the quarterly X values in this example). This appears to be a limitation of what is possible with the Plotly API.

image.png