Skip to content
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

Bottom axis labels not partially hidden when using linear scale #18

Closed
markov00 opened this issue Jan 31, 2019 · 4 comments · Fixed by #38
Closed

Bottom axis labels not partially hidden when using linear scale #18

markov00 opened this issue Jan 31, 2019 · 4 comments · Fixed by #38
Assignees
Labels
bug Something isn't working

Comments

@markov00
Copy link
Member

If you use a dataset with more than 10 x values, seems that the we don't correctly computed the bottom axis label width.
Can be reproduced using the following to generate a simple dataset:

import { DataGenerator } from '../utils/data_generators/data_generator';

const dg = new DataGenerator();
const data = dg.generateSimpleSeries();

...
<AreaSeries
    id={getSpecId('area')}
    xScaleType={ScaleType.Linear}
    yScaleType={ScaleType.Linear}
    xAccessor="x"
    yAccessors={['y']}
    data={data}
/>

screenshot 2019-01-31 at 22 13 47

The axis values are correct, but seems to be cutted off:
0, 5, 1, 1, 2, 2, 3, 3, 4, 4 instead of
0, 5, 10, 15, 20, 25, 30, 35, 40, 45

@markov00 markov00 added the bug Something isn't working label Jan 31, 2019
@markov00
Copy link
Member Author

I've found a workaround using the same value of maxLabelBboxWidth for maxLabelTextWidth but I think it's better to dig a bit more here

@emmacunningham
Copy link
Contributor

Ah interesting, thanks for catching this! Will investigate :)

@emmacunningham
Copy link
Contributor

@markov00 Hrm strangely I cannot seem to reproduce this... This is the output for the AreaSeries chart that you shared:

image

I've tried it at different screen sizes as well and tested with various AxisSpec configurations (esp the showOverlappingTicks and showOverlappingLabels configurations), but am still not seeing the labels get truncated. Could you share what AxisSpec configurations you are using? Wondering if it has something to do with a specific set of AxisSpec configs...

@emmacunningham
Copy link
Contributor

Leaving some notes here just to document what I've found so far. We've figured out that this is an issue affecting Chrome but not Firefox. However, upon further investigation, it seems to be very specific to however we're measuring the text of the labels. The labels are getting cut off in Chrome because the computed width is not wide enough (seems to be off by about 0.25px). At first I thought this might have something to do with discrepancies between rendered font families, but this seems to not be the issue since in isolation, the logic to compute the width of the label seems to work as intended and correctly there's not truncation of the text.

I've created an isolated version of how we're computing these text label widths in this CodePen. This mostly just uses the logic that is in the CanvasTextBBoxCalculator.

However, when I call the same measure function in our repo, using the same text input, font size, and font family, the returned value in Chrome is off by about 1px (from both the isolated sandbox version in Chrome as well as the value computed in Firefox).

    const testBbox = bboxCalculator.compute('32', 10, `'Open Sans', Helvetica, Arial, sans-serif`).getOrElse({
      width: 0,
      height: 0,
    });

This returns 11.066666603088379 in Firefox and 11.123046875 in the CodePen in Chrome, which will get bumped up to 12px, creating enough width for the text. However, in the app in Chrome, this returns 10.96304702758789 which then rounds up to 11px, which is not enough width, causing the truncation by Konva.

emmacunningham added a commit to emmacunningham/elastic-charts that referenced this issue Feb 5, 2019
markov00 pushed a commit that referenced this issue Feb 7, 2019
# 1.0.0 (2019-02-07)

### Bug Fixes

* reflect specs ids on legend items when using single series ([8b39f15](8b39f15))
* **axis:** add axisTitleHeight to axis increments ([#29](#29)) ([e34f0ae](e34f0ae)), closes [#26](#26)
* **axis:** fix horizontal title positioning to account for title padding ([08d1f83](08d1f83))
* **axis:** scale tick labels to fix text truncation on chrome ([#38](#38)) ([99c2332](99c2332)), closes [#18](#18)
* **axis:** use titleFontSize for debug rect for horizontal axis title ([#17](#17)) ([af4aa58](af4aa58)), closes [#11](#11)
* **dimensions:** use chart top padding in computation of chart height ([42585f7](42585f7)), closes [#13](#13)
* **x_domain:** fix x value asc sorting using numbers ([26b33ff](26b33ff))

### Features

* add tickLabelRotation and showGridLines features ([#7](#7)) ([47f118b](47f118b))
* **axis:** draw grid lines separately from axis tick and customize style with config ([#8](#8)) ([ab7e974](ab7e974))
AMoo-Miki pushed a commit to AMoo-Miki/OpenSearch-Dashboards that referenced this issue Feb 10, 2022
# 1.0.0 (2019-02-07)

### Bug Fixes

* reflect specs ids on legend items when using single series ([ecbe4c6](elastic/elastic-charts@ecbe4c6))
* **axis:** add axisTitleHeight to axis increments ([opensearch-project#29](elastic/elastic-charts#29)) ([1f4b48b](elastic/elastic-charts@1f4b48b)), closes [opensearch-project#26](elastic/elastic-charts#26)
* **axis:** fix horizontal title positioning to account for title padding ([d167af6](elastic/elastic-charts@d167af6))
* **axis:** scale tick labels to fix text truncation on chrome ([opensearch-project#38](elastic/elastic-charts#38)) ([3e6a400](elastic/elastic-charts@3e6a400)), closes [opensearch-project#18](elastic/elastic-charts#18)
* **axis:** use titleFontSize for debug rect for horizontal axis title ([opensearch-project#17](elastic/elastic-charts#17)) ([7e5f7d6](elastic/elastic-charts@7e5f7d6)), closes [#11](elastic/elastic-charts#11)
* **dimensions:** use chart top padding in computation of chart height ([4bc5ac8](elastic/elastic-charts@4bc5ac8)), closes [#13](elastic/elastic-charts#13)
* **x_domain:** fix x value asc sorting using numbers ([f64c6aa](elastic/elastic-charts@f64c6aa))

### Features

* add tickLabelRotation and showGridLines features ([#7](elastic/elastic-charts#7)) ([ced76ce](elastic/elastic-charts@ced76ce))
* **axis:** draw grid lines separately from axis tick and customize style with config ([#8](elastic/elastic-charts#8)) ([411950b](elastic/elastic-charts@411950b))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants