juttle / juttle-viz

Juttle Visualization Library
Apache License 2.0
11 stars 4 forks source link

Timechart series labels in the legend sometimes get truncated #28

Open dmehra opened 8 years ago

dmehra commented 8 years ago

When specifying secondary yScale for a series, resulting series names in the timechart legend get truncated even though there is plenty of free space. The truncation does not happen for the same names when using primary yScale. The use of -keyField doesn't affect truncation either way.

However, sometimes you can use much longer names without them getting chopped off, on primary or secondary axis, so I cannot narrow down the reproduction scenario.

This Juttle does reproduce the problem:

(
  emit -limit 100 -from :today: -every :minute: | put name = "Close", value = 100;
  emit -limit 100 -from :today: -every :minute: | put name = "Volume", value = 40;
)
| view timechart
  -series [
        {name: 'Close', geom: 'line', yScale: 'primary'},
        {name: 'Volume', geom: 'bars', yScale: 'secondary'}
    ];

image

Same but on primary yScale, no truncation:

(
  emit -limit 100 -from :today: -every :minute: | put name = "Close", value = 100;
  emit -limit 100 -from :today: -every :minute: | put name = "Volume", value = 40;
)
| view timechart
  -keyField 'name'
  -series [
        {name: 'Close', geom: 'line', yScale: 'primary'},
        {name: 'Volume', geom: 'bars', yScale: 'primary'}
    ];

image

Here is an example with much longer name, but using primary axis, and still no truncation:

(
  emit -limit 100 -from :today: -every :minute: | put name = "Close", value = 100;
  emit -limit 100 -from :today: -every :minute: | put name = "Volume (Such Long Name)", value = 40;
)
| view timechart
  -series [
        {name: 'Close', geom: 'line', yScale: 'primary'},
        {name: 'Volume (Such Long Name)', geom: 'bars', yScale: 'primary'}
    ];

image

But there must be more to this, because here is code that uses long names for both axes and no truncation happens:

(
  emit -limit 100 -from :today: -every :minute: | put name = "Closing", value = 100;
  emit -limit 100 -from :today: -every :minute: | put name = "Volume (Such Long Name)", value = 40;
)
| view timechart
  -series [
        {name: 'Closing', geom: 'line', yScale: 'secondary'},
        {name: 'Volume (Such Long Name)', geom: 'bars', yScale: 'primary'}
    ];

image

dmehra commented 8 years ago

Note that this happens in our demo example stock_prices.juttle:

image