2
  chart3 = new Highcharts.Chart({
                chart: {
                    renderTo: 'container3',
                    type: 'column'
                },
                title: {
                    text: 'Cumplimiento de los Programas del PMA-Contratistas'
                },
                subtitle: {
                    text: ''
                },
                xAxis: {
                    categories: [
                        'Nº Charlas ambientales',
                        'Nº personal capacitado'

                    ]
                },
                yAxis: {
                    min: 0,
                    title: {
                        text: '%'
                    }
                },
                legend: {
                    layout: 'vertical',
                    backgroundColor: '#FFFFFF',
                    align: 'left',
                    verticalAlign: 'top',
                    x: 100,
                    y: 70,
                    floating: true,
                    shadow: true
                },
                tooltip: {
                    formatter: function() {
                        return ''+
                            this.x +': '+ this.y +' mm';
                    }
                },
                plotOptions: {
                    column: {
                        pointPadding: 0.2,
                        borderWidth: 0
                    }
                },
                series: [{name: 'Semana',data: [12   , 321]  }, {name: 'Acum',data: [85, 65]}]
            });

this is my Highchart code

when I am using javascript variable

like this

  g311 = $("#g311").val();
        g312 = $("#g312").val();
        g321 = $("#g321").val();
        g322 = $("#g322").val();

and pass this in series

   series: [{name: 'Semana',data: [g311, g312]  }, {name: 'Acum',data: [g321, g322]}]

it is not showing me graph please give me some way how to pass jquery variable in series (not static or PHP variable)

1
  • 1
    Can you clarify your question? As long as you do your g311 = ... lines before your new Highcharts.Chart line, and as long as the elements you're referring to exist as of when you do your g311 = $("#g311") and similar, and if those are inputs with values in them, it should work. Commented Jun 13, 2014 at 10:41

1 Answer 1

5

Seems to me you need to convert them to numbers first because input elems have values as strings:

g311 = +$("#g311").val();
g312 = +$("#g312").val();
g321 = +$("#g321").val();
g322 = +$("#g322").val();

and you need to declare these above the chart.

prefixing + converts a string to number.

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks @jai .....you actually understood my problem seems like you have faced this one :D Bless You Thanks
you can also use parseFloat() function.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.