palantir / plottable

:bar_chart: A library of modular chart components built on D3
http://plottablejs.org/
MIT License
2.96k stars 223 forks source link

Support custom font sizes #3584

Closed michael-yx-wu closed 2 years ago

michael-yx-wu commented 2 years ago

Add support for custom label font size in the following places:

cc @nifdee @billytrend

Testing

SVG measures distance to text elements using the text baseline instead of the top-left corner like it does with most other elements. I've taken care to redraw or reset the typesettable measurer's cache where applicable to make subsequent renders draw the text in the right place. When playing with the quicktests, please double check that the label is positioned reasonably as font size changes i.e. it doesn't crowd out other elements, it's hidden when there is no space to draw, etc.

⚠️ The blueprint-bot's quicktest link is broken, so I recommend testing by checking out the repo and running yarn start and navigate to the links below. Gifs show what you should expect to see. I recommend using node 8.10.0 with this repo, just to be consistent with the CI environment.

Bar

http://localhost:9999/quicktests/dev/index.html#functional/bar_plot_label_font_size 2021-10-11 21 48 16

Scatter

http://localhost:9999/quicktests/dev/index.html#functional/scatter_plot_label_font_size Something weird is happening w/ the scatter plot labels. Unclear why the size "stutters" when increasing font size. Note that internally, we do not use scatter plot labels. 2021-10-11 21 27 59

Category axis

http://localhost:9999/quicktests/dev/index.html#functional/category_axis_label_font_size 2021-10-11 21 27 52

Numeric axis

http://localhost:9999/quicktests/dev/index.html#functional/numeric_axis_label_font_size 2021-10-11 21 27 36

Time axis

http://localhost:9999/quicktests/dev/index.html#functional/time_axis_label_font_size 2021-10-11 21 27 23

blueprint-bot commented 2 years ago

Fix lint

Demo: quicktests | fiddle

blueprint-bot commented 2 years ago

Rerender after setting plot font size

Demo: quicktests | fiddle

blueprint-bot commented 2 years ago

Support custom label font size in axes and scatter

Demo: quicktests | fiddle

blueprint-bot commented 2 years ago

Lint

Demo: quicktests | fiddle

blueprint-bot commented 2 years ago

Clean up jsdoc

Demo: quicktests | fiddle

blueprint-bot commented 2 years ago

Address nits

Demo: quicktests | fiddle