3.1.7 • Published 3 months ago

@komgrip/nuxt-highcharts v3.1.7

Weekly downloads
-
License
MIT
Repository
github
Last release
3 months ago

nuxt-highcharts

npm version npm npm.io npm.io License

Highcharts for Nuxt

📖 Release Notes

Setup

  1. Add nuxt-highcharts dependency to your project
npm i nuxt-highcharts

NOTE: if working with highcharts 11, you need to remember to convert your data from the Proxy type to a type supported by Highcharts. For example, if you have reactive data this.points, you'll need to set the Highcharts data with something like: Array.from(this.points)

  • These are the module's required dependencies:

  • These are the module's optional dependencies:

    • @highcharts/map-collection - Collection of maps to use with Highmap. Please be aware of their LICENSE. This module uses it strictly for demo purposes (and is non-profit, open-source).
  1. Add nuxt-highcharts to the modules section of nuxt.config.js
{
  modules: [
    // Simple usage
    'nuxt-highcharts',

    // With options
    ['nuxt-highcharts', { /* module options */ }]
  ],
  highcharts: {
    /* module options */
  }
}

Quick-Start Example

  1. For the impatient that "just need it to work", this is your easiest option!
<highchart :options="chartOptions" />
  1. If you plan to only change the title and series data, this will update the chart faster than the previous example:
<highchart 
  :options="chartOptions" 
  :update="['options.title', 'options.series']" 
/>
  1. Looking for more? The most up-to-date examples are in this git repo!. The demo uses this repo directly!

Module Options

OptionTypeDescription
chartOptionsObjectDefault chart options to use for the highchart components. These get wired to Highcharts. Useful tip: import('highcharts/highcharts').Options to get intellisense suggestions
exportingBooleanEnable/disable the exporting feature globally
setOptionsObjectOptions to use globally, that get sent to Highcharts.setOptions. For example, decimal point separator ('.' or ','). Useful tip: import('highcharts/highcharts').Options to get intellisense suggestions

The above options can also be provided as props to the highcharts components. When provided as props, the props will be used instead. Module options are useful when you want the same feature applied globally, like exporting. Props are preferred when you only want to have those options affect individual components.

Components

The nuxt-highchart module adds a plugin which registers the following components:

NameDescription
highchartThe basic chart component (but still very powerful! see the demo)
highstockThe highstock chart component, shorthand for `
highmapThe highmap chart component, shorthand for `

Props (extends and overrides module options)

OptionTypeDefaultDescription
animationObject{}Animation options Chart.update. This is where you can specify animation duration.
exportingBooleanmoduleOptions.exporting || falseEnable/disable the exporting feature globally
highchartsObjectHighchartsThe Highcharts instance to use, defaults to an instance imported by the plugin.
mapObject{ mapName: 'myMapName', mapData: [you provide this, see examples] }Options for the Highmap chart. The mapData can be either the JSON or string pointing to the json file
modulesArray\<String>Highcharts modules to load. These modules are in node_modules/highcharts/modules/*.js
moreBooleanfalseEnable/disable highcharts-more. Some charts, such as polar and bubble, require this to be enabled. NOTE: Highcharts library deliberately leaves out the features to avoid bloating the library. Only specify more when you want those extra features
oneToOneBooleantrueOne-to-One option for Chart.update
optionsObjectmoduleOptions.chartOptions || {}Default chart options to use for the highchart components. These get wired to Highcharts. Useful tip: import('highcharts/highcharts').Options to get intellisense suggestions
redrawBooleantrueRedraw option for Chart.update
setOptionsObjectmoduleOptions.setOptionsOptions to use globally, that get sent to Highcharts.setOptions. For example, decimal point separator ('.' or ','). Useful tip: import('highcharts/highcharts').Options to get intellisense suggestions
updateArray["options"]Contains an array of specific options to watch. Is extremely useful for speeding up the reactivity! Default: "options".

The following watchers are currently supported:

  • "options": watch deep all the options' properties. Easy to use, but can impact performance.
  • "options.caption"
  • "options.series"
  • "options.subtitle"
  • "options.title"
  • "options.yAxis"
  • "options.xAxis"

The plugin will also inject $highcharts into the current context, so that on any component, you can access the following properties:

  • $highcharts.chartTypes - various chart types
  • $highcharts.components - the components registered by the plugin

Events

EventDescription
chartLoadedEmitted after successfully mounting any of the above components. It will provide an instance of the chart, so should you wish to use the Highchart API directly you can using that instance.

Run-time config

The following run-time config variables are also available in this.$config.nuxtHighcharts:

VariableDescription
pluginOptionsThe module options that were passed to the plugin
hcModNamesList of the highcharts modules you can load

Development

  1. Clone this repository
  2. Install dependencies using yarn install or npm install
  3. Start development server using npm run dev

License

MIT License

Copyright (c) Richard Schloss richard.e.schloss@protonmail.com

3.1.7

3 months ago

3.1.6

3 months ago

3.1.5

3 months ago

3.1.4

3 months ago

3.1.3

3 months ago

3.1.2

3 months ago