Get the height of the charts

I would like to get the current width of the chart, I tried something like this:

chart.width

and

$(this).parent().width()

where is the schedule

chart = new Highcharts.Chart({ ... })

But does not work ...

ADDITIONAL INFORMATION

I would like to place an image (helper) to the left of the export buttons (responsive).

At the moment, I have the following code:

$(document).ready(function() {
     chart = new Highcharts.Chart({
        chart: {
            renderTo: 'area1',
            type: 'bar',
            events: {
                load: drawImages,

            }
         ...}
      })
    })

AND

function drawImages() {
    var chart = this;
    x = chart.plotRight - 50

    chart.renderer.image('/assets/faq.png', x, 0, 20, 20)

    .attr({
        zIndex: 100,
        title: "My title for displaying a tooltip"
    })
    .css({
        cursor: 'pointer'
    })
    .add();   
    };

But images are displayed on the left side of the chart (using plotRight).

I know how to get the width of the container div of the graph ("area1"), but I like to have code larger than Object Oriented (because I have at least 5 graphics on the page).

+5
source share
3 answers

Finally, I found a solution using the "container" method:

$(chart.container).width()

This returns the current width of the chart.

+6
source

chartWidth, .

http://jsfiddle.net/7xNQL/1/

//callback
    function(chart){

                console.log(chart.chartWidth);

            }
+13

You can use xAxis extreme.max and translate it into pixels. Something like (not verified):

Chart.xaxis[0].toPixels( chart xaxis[0].getExtremes().max )

It seems like there should be a simpler way, but I assume I would use the used div width. Perhaps you could use the parameters of the chart to get the containing div I would and get the width from this.

+2
source

All Articles