Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7629537
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T05:51:36+00:00 2026-05-31T05:51:36+00:00

I am having multiple highchart charts of various types(Bar,Pie, Scatter type) in a single

  • 0

I am having multiple highchart charts of various types(Bar,Pie, Scatter type) in a single web page. Currently I am creating config object for each graph like,

{
chart : {},
blah blah,
}

And feeding them to a custom function which will just call HighCharts.chart(). But this results in duplication of code. I want to manage all this chart rendering logic centrally.

Any Idea on how to do this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T05:51:37+00:00Added an answer on May 31, 2026 at 5:51 am

    You can use jQuery.extend() and Highcharts.setOptions.
    So first you’ll make the first object which will be extended by all your charts, this object will contain your Highchart default functions.

    You can do it using namespacing.
    The following way is good when you have very different charts.

    Default graphic:

    var defaultChart = {
        chartContent: null,
        highchart: null,
        defaults: {
    
            chart: {
                alignTicks: false,
                borderColor: '#656565',
                borderWidth: 1,
                zoomType: 'x',
                height: 400,
                width: 800
            },
    
            series: []
    
        },
    
        // here you'll merge the defauls with the object options
    
        init: function(options) {
    
            this.highchart= jQuery.extend({}, this.defaults, options);
            this.highchart.chart.renderTo = this.chartContent;
        },
    
        create: function() {
    
            new Highcharts.Chart(this.highchart);
        }
    
    };
    

    Now, if you want to make a column chart, you’ll extend defaultChart

    var columnChart = {
    
        chartContent: '#yourChartContent',
        options: {
    
            // your chart options
        }
    
    };
    
    columnChart = jQuery.extend(true, {}, defaultChart, columnChart);
    
    // now columnChart has all defaultChart functions
    
    // now you'll init the object with your chart options
    
    columnChart.init(columnChart.options);
    
    // when you want to create the chart you just call
    
    columnChart.create();
    

    If you have similar charts use Highcharts.setOptions which will apply the options for all created charts after this.

    // `options` will be used by all charts
    Highcharts.setOptions(options);
    
    // only data options
    var chart1 = Highcharts.Chart({
        chart: {
            renderTo: 'container1'
        },
        series: []
    });
    
    var chart2 = Highcharts.Chart({
        chart: {
            renderTo: 'container2'
        },
        series: []
    });
    

    Reference

    • http://api.highcharts.com/highcharts#Highcharts.setOptions%28%29

    COMPLETE DEMO

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having multiple <form> on single page, all having unique IDs, and the form
I am having difficulty getting multiple jPicker instances of the same type to display
I am using a form page having multiple steps in it i want to
In my project one of the model named types having multiple relation to other
I am having multiple jQuery sliding panel in the same page, however when i
I am having multiple dropdownlists in my aspx page. Reletively I am populating all
Having multiple forms in one page, when i submit one of them, how can
The way I currently handle this is by having multiple config files such as:
I have an ASP.NET web application where i am having multiple subrirectories in the
I am having multiple views which are databind to single view model. Now i

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.