jquery - HTML displaying values in JavaScript "data" -


the following javascript code used display table data chart.

  <script type="text/javascript">         $(function () {             $('#container').highcharts({                 data: {                     table: 'datatable'                 },                 chart: {                     type: 'column'                 },                 title: {                     text: 'results'                 },                 yaxis: {                     allowdecimals: false,                     title: {                         text: 'units'                     }                 },                 tooltip: {                     formatter: function () {                         return '<b>' + this.series.name + '</b><br/>' +                             this.point.y + ' ' + this.point.name.tolowercase();                     }                 }             });         });     </script> 

html code holds data:

<div id="container" style="min-width: 310px; height: 400px; margin: 0 auto"></div>  <table id="datatable">     <thead>         <tr>             <th></th>             <th>jane</th>             <th>john</th>         </tr>     </thead>     <tbody>         <tr>             <th>apples</th>             <td>3</td>             <td>4</td>         </tr>         <tr>             <th>pears</th>             <td>2</td>             <td>0</td>         </tr>     </tbody> </table> 

i have following values in html:

<div id="name"> </div> <div id="age"></div> 

"name" , "age" hold different values. how can implement values chart instead of data: (jane, john, apples,pears). possible?

http://jsfiddle.net/gh/get/jquery/1.9.1/highslide-software/highcharts.com/tree/master/samples/highcharts/demo/column-parsed/

that kind of how chart displaying atm. can put "name" , "age" on chart instead?

your question bit vague i'll try best help. i'm sure provide better answer if more information provided such as:

  • what data want show on chart?

  • what value want measured? example, measuring years?

  • measuring different elements of same person or same elements different people?
  • i'm assuming when stated want display "name" , "age" on chart instead of what's provided in example, want display names age being measuring value. if that's case here's came with.

    jsfiddle: javascript highchart example age measuring value

    html code

    <div id="container" style="min-width: 310px; max-width: 800px; height: 400px; margin: 0 auto"></div> 

    javascript code

    $(function () {     $('#container').highcharts({         chart: {             type: 'bar'         },         title: {             text: 'age of major life events'         },         subtitle: {             text: 'created by: <a href="http://www.rocketrisa.com">rocket risa</a>'         },         xaxis: {             categories: ['john', 'jane', 'jessica', 'jordan', 'jeri'],             title: {                 text: null             }         },         yaxis: {             min: 0,             title: {                 text: 'age (years)',                 align: 'high'             },             labels: {                 overflow: 'justify'             }         },         tooltip: {             valuesuffix: ' years'         },         plotoptions: {             bar: {                 datalabels: {                     enabled: true                 }             }         },         legend: {             layout: 'vertical',             align: 'right',             verticalalign: 'top',             x: -40,             y: 80,             floating: true,             borderwidth: 1,             backgroundcolor: ((highcharts.theme && highcharts.theme.legendbackgroundcolor) || '#ffffff'),             shadow: true         },         credits: {             enabled: false         },         series: [{             name: 'teen',             data: [15, 13, 18, 14, 17]         }, {             name: 'young adult',             data: [23, 28, 21, 25, 27]         }, {             name: 'middle age 30+',             data: [35, 46, 32, 64, 51]         }]     }); }); 

    Comments

    Popular posts from this blog

    html - Styling progress bar with inline style -

    java - Oracle Sql developer error: could not install some modules -

    Django REST Framework perform_create: You cannot call `.save()` after accessing `serializer.data` -