score:4
Accepted answer
You can make a variable for the options that are in common, like:
var commonOptions = {
chart: {
type: 'area'
},
// ...
};
And then merge in the specific options for each chart like this:
$('#container').highcharts(Highcharts.merge(commonOptions, {
series: [{
name: 'Tokyo',
data: [7.0, 6.9, 9.5, 14.5, 18.2, 21.5, 25.2, 26.5, 23.3, 18.3, 13.9, 9.6]
}]
// ...
}));
See this JSFiddle example with legend, tooltip and series options.
score:3
How about creating function like createChart
? And passing on variables? Like this: http://jsfiddle.net/0s2pkps0/2/
newChart('#chart-1', 'Date', 'Count', series_1);
newChart('#chart-2', 'Weekly report', 'Total views', series_2);
function newChart(container, xAxisTitle, yAxisTitle, series) {
$(container).highcharts({
chart: {
type: 'area'
},
xAxis: {
type: 'datetime',
dateTimeLabelFormats: {
day: '%eth %b'
},
title: {
text: xAxisTitle,
}
},
yAxis: {
title: {
text: yAxisTitle
},
},
series: series
});
}
Source: stackoverflow.com
Related Query
- Highcharts - Global configuration with common code and unique data & Headings
- Highcharts data series issue with ajax/json and PHP
- Highcharts with JSON data and multiple series
- How to structure Angular with Highcharts and lots of dynamic data
- Creating a line graph with highcharts and data in an external csv
- Highcharts v3.0.1 problems with rotating data labels in IE8 and jQuery v1.7.1
- Data with timestamp group to month(like Jan, Feb, March) and showing as total count for month in Highcharts
- Highcharts with ajax and json data what am i doing wrong?
- Highcharts show the same yAxis start and end value with multiple data series
- HighCharts & MVC: How to load whole graph definition and data with JSON?
- Highcharts with datetime and also additional data (tooltip text)
- Highcharts - selection error with live data and different time intervals
- Using yii with dynamic data and highcharts
- Highcharts single horizontal stacked bar chart with data names (labels) and %-ages always shown and data numbers and series name shown on mousehover
- Highcharts series visibility with csv data source
- How to have multiple highcharts with different series data in vuejs without repeating code
- PIE CHART - Data Visualization With DataTables and Highcharts
- Dynamic column based highcharts feeding data with jquery and php
- Static Highcharts graphic with external csv data and dynamic footnote
- Static Highcharts graphic with csv data and dynamic footnote
- Highcharts to display area range and line chart with data from a CSV file
- d3 and Highcharts diagram with parent and common node
- Highcharts AreaRange Chart issues with xAxis and last data point label
- Highcharts cloud issue with data source when duplicating chart
- how to make chart real time with 2 line and get data from php with highcharts
- Using Highcharts with minutes, seconds and milliseconds as Data not working
- Plot line is hiding behind trend in highcharts and movement of plotline is become very hindrance when loaded with very large data sets
- Highcharts bar chart with negative and positive data
- Load highcharts data with laravel and ajax
- Highcharts - Get and plot data with MySQLi + JSON (step by step)
More Query from same tag
- React Highcharts include plugins
- change navigator date format in highstock
- HTML5/High Charts - Truncate xAxis Labels
- How to serialize JSON without outputting quotes around certain values
- Highchart dual y-axes with same base and smaller tickinterval
- Highcharts - draw path on chart with datetime axis
- HighCharts full width issue
- Old state is being shown despite updating in React Highcharts click event
- Highcharts showing points on hovering over the line which are outside the chart area when the chart is zoomed in
- Can't get full screen buttons to work with highcharts-vue
- Coloring treemap by parent node in highcharts styled mode
- Error displaying Gantt chart in laravel
- R different colours for set of bars in barchart
- Highcharts: x-value as date
- Drag multiple points at one time in highcharts
- Possibilities/advise for creating a grid-like Dashboard with graphs (highcharts)?
- How do you remove x-axis labels from a highchart.js bar chart
- Highcharts: Not plotting correctly with Y-Axis label formatter
- Multiple categories and series in Highcharts
- Highcharts bar chart x-axis inconsistent behaviour
- How do I export the current styling of a HighChart series chart to PNG, JPG or PDF?
- highcharts different tick interval
- Highcharts: X and Y Axis cross at zero in scatter chart
- Loading Highcharts via shim using RequireJS and maintaining jQuery dependency
- How can I use variable in Highchart?
- Colors doesn't change using Highcharts.setOptions
- Highcharts: Dynamically change single column width to highlight one sample
- Dynamic Input to Highcharts via HTML input field?
- How to make highcharts default to 0 for missing data
- Is there any replacement of "zones" in highcharts?