Repair and improve automated and manual chart axis scale management for time and numeric scales
In Chart Generator as well as in .Stat Suite Data Explorer, repair and improve the chart axes scale management for both time and numeric scales
Repair the following features:
-
For automated time scales, time period step is not big enough and labels overlap (see example 1) -
For automated numeric scales, the step is often not big enough and labels are too close or even overlap and are not rounded at the appropriate digit (see examples 2A and 2B) -
Using numerical values with decimals for min, max and step for numeric scales do not work but need to be supported (see example 3) -
A manually set pivot value for numeric scales doesn't remove the thick line of the default pivot value (0) (see example 4) -
Not able to identify the frequency and display a timeline chart when no FREQUENCY dimension and no TIME_FORMAT attribute are modelled. (see example 5) It would be good to guess the frequency from the distance of the first two time periods (frequency:=duration(period2-period1) (or in the same way as the Time Period filter does?).
Requirements for automatically calculated humanly nice chart axes scales:
- According to Chart Graphique drop axes grids and ticks for too small charts
- Configure a minimum (for small charts) and a maximum (for bigger charts) for the step size (in number of pixels) depending on the text to be displayed and respect these limits (e.g. for numeric y-axis min: twice the text height and max: 5 times the text height, for horizontal time scale min: the text width of the first period including three additional empty spaces, but no maximum step size for horizontal time scale)
- For numeric axis:
- When axes grids and ticks are shown then limit tick numbers to very few (2 or 3 max depending on space) for small charts (as long as the step size (in number of pixels) is smaller than the above allowed maximum
- Start increasing tick number only when step size (in number of pixels) reaches its maximum
- Calculated numeric step sizes must always be a number x*10^n with n being any number and with x being equal to:
- 1, 1.5, 2, 2.5 or 5 when having more than 6 ticks
- 1, 1.5, 2, 3, 4 or 5 when having more than 2 and less than 7 ticks
- 1, 2, 3, 4, 5, 6, 7, 8 or 9 when having 2 ticks (only 1 step)
- The Step chosen should allow to stay as close as possible to the limits given by the minimum and maximum values, and to allow to display all values (unless there are user-defined maximum or minimum values)
- Steps are applied upward or downward from the pivot if a pivot is given
- Steps are applied upward from the minimum if there is no pivot given
- The default 0 pivot is shown only if the calculated span between min and max include 0
- User-defined min, max, step and pivot must always be respected if mathematically possible. In case of several ticks, the step sizes to the first and last ticks could be different from the imposed step size and pivot if (max-min), (max-pivot) or (pivot-min) are not multiples of the step.
- Horizontal time scale (except for tiny charts without time line scale according to Charte Graphique):
- show one major tick per year (for frequencies equal or higher than annual (e.g. monthly), otherwise for each time period) if there is enough space to put also their labels (see above), otherwise show one major tick per smallest possible multiple of years (or of multi-year periods)
- the end period is calculated as multiple of the major tick step starting from the start period; the calculated end period is as close as possible to and equal or greater than the last time period of the data.
- show minor ticks for time periods if there is enough space to visually distinguish the tick from neighboured ticks (e.g. 1 tick requires a minimum horizontal space of 4 pixels), otherwise per year (for frequencies equal or higher than annual (e.g. monthly), otherwise for each time period)
- show labels for time periods with just enough space for labels (see above) in a constant rhythm that includes major ticks (when major tick step % label step = 0)
- The user can set the step for labels and it is applied only if there will be enough space for labels (see above) and if major tick step % label step = 0
Example JS-based library implementing the required automatically calculated humanly nice chart axes scales:
Examples:
(1)
With this set of data [QNA/AUS+CAN+FRA+DEU+ITA+JPN+KOR+MEX+TUR+GBR+USA+EU28+G-20+ARG+BRA+CHN+IND+IDN+ZAF.B1_GE.GPSA.Q/all?startTime=2000-Q1&endTime=2019-Q4], the chart-generator the automated time scale ticks are to close and labels get overlapped. The timeline chart's x-axis step option should be placed below an x-axis header.
(2)
A) With this set of data http://de-qa-oecd.redpelicans.com/vis?dataquery=OECDE..&period=2015%2C2020&frequency=A&locale=en&facet=Topics&constraints[0]=Topics%2C0%7CEnvironment%23ENV%23&start=0&dataflow[datasourceId]=staging%3ASIS-CC-stable&dataflow[dataflowId]=AIR_EMISSIONS_DF&dataflow[agencyId]=OECD&dataflow[version]=1.0&filter=COU&viewer=BarChart, the automatically calculated step is too small and not rounded at the appropriate digit reducing the usability of the grid lines:
Height and width are both set to 400.
B) With this set of data http://de-qa-oecd.redpelicans.com/vis?dataquery=A.NLB..S13._T._T._T.&period=%2C2017&frequency=A&locale=en&facet=Topics&constraints[0]=Topics%2C0%7CEducation%23EDU%23&start=0&dataflow[datasourceId]=staging%3ASIS-CC-stable&dataflow[dataflowId]=DF_GOV_1&dataflow[agencyId]=OECD.GOV&dataflow[version]=2.0&filter=PANEL_USED_FILTERS&viewer=TimelineChart, the numeric and time axes steps are too small and labels overlap
Height and width are set to 399 and 250.
(3)
With this set of data (QNA/AUS+CAN+FRA+DEU+ITA+JPN+KOR+MEX+TUR+GBR+USA+EU28+G-20+ARG+BRA+CHN+IND+IDN+ZAF.B1_GE.GPSA.Q/all?startTime=2019-Q2&endTime=2019-Q3), decimal value instead of integer is useful for the step option, specifically for small numeric value (percentage between two periods)
The decimal step option has not been taken into consideration. The minimum and maximum options did not accept decimals (such as max=1.75 or 1,75 and minimum -0.75 or -0,75)
(4)
With this set of data http://de-qa-oecd.redpelicans.com/vis?dataquery=A.NLB..S13._T._T._T.&period=%2C2017&frequency=A&locale=en&facet=Topics&constraints[0]=Topics%2C0%7CEducation%23EDU%23&start=0&dataflow[datasourceId]=staging%3ASIS-CC-stable&dataflow[dataflowId]=DF_GOV_1&dataflow[agencyId]=OECD.GOV&dataflow[version]=2.0&filter=PANEL_USED_FILTERS&viewer=TimelineChart, and the y-axis pivot value set to 10, the chart displays 2 thick pivot lines, one at 0 and one at 10, but only the grid line at 10 should be thicker.
(5)
With this set of data http://de-qa-oecd.redpelicans.com/vis?dataquery=..H511..PERSONS&period=%2C&frequency=A&locale=en&facet=Topics&constraints[0]=Topics%2C0%7CEducation%23EDU%23&start=0&dataflow[datasourceId]=staging%3ASIS-CC-stable&dataflow[dataflowId]=DF_TOURISM_EMP&dataflow[agencyId]=OECD.CFE&dataflow[version]=1.1&viewer=TimelineChart&filter=PANEL_PERIOD, the timeline chart cannot be displayed because no FREQUENCY dimension and no TIME_FORMAT attribute are modelled.