Skip to content

layout→font→family: 'inherit' does not work as expected #3027

Closed
@anders-kiaer

Description

@anders-kiaer

Enabling a custom global font-family in a plotly.js plot is today possible using layout → font → family, which has default value "Open Sans", verdana, arial, sans-serif. See this pen for an example of including custom font.

This works well in cases where you know the font-family to use up front. In some cases plotly.js is used for making a plot, and the output is placed in a framework/context where the user controls the font in use.

Getting plotly.js output to inherit the font-family currently in use could maybe potentially be as simple as layout: {font: {family: 'inherit'}}, however this does not currently work as there seems to be a hard-coded value of "Open Sans", verdana, arial, sans-serif still given by plotly.js as style attribute higher in the DOM tree (which is then inherited by the plotly.js-created elements actually having font-family: inherit).

This is a stack overflow post apparently facing the same issue.

There exist workarounds like window.getComputedStyle(my_div_element,null).getPropertyValue("font-family"); and then get plotly.js to use the dynamically computed font-family, but it would be easier if plotly.js could inherit directly.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions