We help IT Professionals succeed at work.
Get Started

Highcharts from table (cross-tab/pivot format)

av8or16 asked
Last Modified: 2012-06-21
I need to visualize table data in highcharts, but I have two formats for how data is displayed in a table.

The first method works just fine when the series data are in columns see highcharts example  , but I run into problems when my data table is setup in cross-tab/pivot format (series data are in rows).

<table id="datatable" class="tablesorter">

Open in new window

Is there a modification I can make to the table parse to generate the way I need it?
header is the x-axis (i have already modified the code to make this work, not shown below)
first column of each row is the series name (shown in legend)
and data are all subsequent columns in the row

this is the standard parse that works with my regular tables:

options.xAxis.categories = [];
   $('tbody th', table).each( function(i) {
   // the data series
   options.series = [];
   $('tr', table).each( function(i) {
      var tr = this;
      $('th, td', tr).each( function(j) {
         if (j > 0) { // skip first column
            if (i == 0) { // get the name and init the series
               options.series[j - 1] = { 
                  name: this.innerHTML,
                  data: []
            } else { // add values
               options.series[j - 1].data.push(parseFloat(this.innerHTML));

Open in new window

Thanks in advance
Watch Question
This problem has been solved!
Unlock 1 Answer and 1 Comment.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE