Add ability to override default font provided with Highchart

Created on 7 February 2023, over 1 year ago
Updated 8 February 2023, over 1 year ago

Problem/Motivation

Our client has asked for the ability to use our themes' font in our implementation of the Highcharts Charts module.

Steps to reproduce

Enable Highcharts as the chart for Charts module & look through the code / config forms & see that there is no option to set a font-family.

Proposed resolution

Add a field to the Highcharts config settings form to allow user to select which font-family to use for the forms.

User interface changes

New field in Highcharts config settings form.

API changes

In the highcharts API docs, it is posted here to set the font-family like so using options.chart.style.fontFamily
https://www.highcharts.com/forum/viewtopic.php?t=7096#:~:text=You%20can%...

✨ Feature request
Status

Closed: works as designed

Component

User interface

Created by

πŸ‡ΊπŸ‡ΈUnited States redbrickone

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @redbrickone
  • Status changed to Needs review over 1 year ago
  • πŸ‡ΊπŸ‡ΈUnited States andileco

    Hi @redbrickone - you can already do that using the Charts API (see: https://git.drupalcode.org/project/charts/-/blob/5.0.x/charts.api.php#L117)

    This works but replace 'serif' with your font of choice:

    function MY_THEME_chart_definition_alter(array &$definition, array $element, $chart_id) {
      $definition['chart']['style']['fontFamily'] = 'serif';
    }
    
  • πŸ‡ΊπŸ‡ΈUnited States redbrickone

    Gotcha, thank you! I will look into this. We also found a route just using CSS so we can probably close this issue. I was under the impression we couldn't modify the styles within the chart which doesn't seem to be the case. Thanks for your prompt reply, you rock!

  • Status changed to Closed: works as designed over 1 year ago
  • πŸ‡ΊπŸ‡ΈUnited States andileco

    Thank you! I'll close. By the way, right now this module is really just a placeholder for if/when the Charts Highcharts submodule of the Charts module is removed from Charts. So you are probably better off posting into the Charts queue directly.

Production build 0.69.0 2024