data module and CSV, display data points differently - Javascript highcharts

Javascript examples for highcharts:Chart Data

Description

data module and CSV, display data points differently

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
      <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script> 
      <script type="text/javascript">
$(function() {/*from  w  ww.  j av a 2  s  .c om*/
  $('#container').highcharts({
    chart: {
      events: {
        load: function() {
          console.log(this.series);
          var theSeries = this.series;
          $.each(theSeries, function(i, series) {
            theData = series.data;
            $.each(theData, function(j, point) {
              console.log(point);
              if (point.marker == 1) {
                theSeries[i].data[j].update({
                  marker: {
                    symbol: 'triangle'
                  }
                });
              }
            });
          });
        }
      }
    },
    title: {
      text: 'Global temperature change'
    },
    subtitle: {
      text: 'Data input from CSV'
    },
    data: {
      csv: document.getElementById('csv').innerHTML,
      firstRowAsNames: true,
      seriesMapping: [{
        marker: 2 // Labels are pulled from column 2 and picked up in the dataLabels.format below
      }]
    },
    plotOptions: {
      series: {
        marker: {
          enabled: true
        }
      }
    },
    series: [{
      lineWidth: 1
    }]
  });
});

      </script> 
   </head> 
   <body> 
      <script src="https://code.highcharts.com/highcharts.js"></script> 
      <script src="https://code.highcharts.com/modules/data.js"></script> 
      <script src="https://code.highcharts.com/modules/exporting.js"></script> 
      <div id="container" style="min-width: 310px; height: 400px; margin: 0 auto"></div> 
      <pre id="csv" style="display:none">x,somedata,marker
1,2,0
2,3,0
3,5,0
4,6,0
5,7,0
6,7,1
7,8,1
8,9,1
9,10,1
10,11,1</pre>  
   </body>
</html>

Related Tutorials