It is currently Thu Apr 24, 2014 12:38 am Advanced search

date with no data, invisible

Technical support for the Highcharts Stock package

date with no data, invisible

Postby chrispo » Wed Feb 08, 2012 2:27 pm

i got a question...

if i got data for 1.1.2012 an 3.1.2012, the chart shows the date 2.1.2012 with no data.
________ - no line - ________
1.1.2012, 2.1.2012, 3.1.2012

is it possible, to make dates with no data like 2.1.2012 invisible? so there is no gap in the chart?
________________
1.1.2012, 3.1.2012

thanks.
chrispo
 
Posts: 5
Joined: Mon Jan 30, 2012 2:30 pm

Re: date with no data, invisible

Postby hfrntt » Fri Feb 10, 2012 3:59 pm

Could you show us your chart and its code?
Slawek Kolodziej
Highcharts support team
hfrntt
 
Posts: 6394
Joined: Mon Aug 30, 2010 10:41 am

Re: date with no data, invisible

Postby chrispo » Sun Feb 12, 2012 5:00 pm

Code: Select all
<!-- 1. Add these JavaScript inclusions in the head of your page -->

   <script type="text/javascript" src="<?php bloginfo('template_url'); ?>/js/highstock/js/highstock.js"></script>
   <script type="text/javascript" src="<?php bloginfo('template_url'); ?>/js/highstock/modules/exporting.js"></script>

   
  <!-- 2. Add the JavaScript to initialize the chart on document ready -->
      <script type="text/javascript">

var options = {
    chart: {
        renderTo: 'container',
      events: {
            load: function() {
                setInterval(function(){
                    requestData();
                }, 120000); // run every 60sek
            }
        }
      
    },
    title: {
        text: 'testing'
    },
   xAxis: {
        type: 'datetime',
      gapGridLineWidth: 0
    },
   rangeSelector: {
   selected : 1,
   buttonTheme: {
                width: null
     },
   buttons: [{
   type: 'month',
   count: 1,
   text: '1 Monat'
}, {
   type: 'month',
   count: 3,
   text: '3 Monate'
}, {
   type: 'month',
   count: 6,
   text: '6 Monate'
}, {
   type: 'all',
   text: '1 Jahr'
}],
   
         inputEnabled: false,
         buttonSpacing: 10
      },
    series:
        []
};

function requestData() {

// Show a CSV file

$.get('/test/<?php echo $chartDataFile;?>', function(data) {

    // Split the lines
    var lines = data.split('\n'),
        series = [{
      name: 'EUR/USD',
         id: 'euro_level',
         type: 'line',
         threshold : null,
         tooltip: {
            yDecimals: 2,
            xDateFormat: '%d.%m.%Y %H:%M Uhr'
         },
       fillColor : {
               linearGradient : {
                  x1: 0,
                  y1: 0,
                  x2: 0,
                  y2: 1
               },
               stops : [[0, Highcharts.getOptions().colors[0]], [1, 'rgba(0,0,0,0)']]
            },
            threshold: null,
            data: []
        }];
    // Iterate over the lines and add categories or series
    $.each(lines, function(lineNo, line) {
    if (lineNo == 0) {
           
         }
         else {
   
        var items = line.split(';'), // trennzeichen
         date = items[0].split('.'), // trennzeichen
         time = items[1].split(':'); // trennzeichen
         if (time[2] == undefined) {
            time[2] = '00';
         }
         
         x = date[2] + '-' + date[1] + '-' + date[0] + 'T' + time[0] + ':' + time[1] + ':' + time[2];
         //alert(x);
         //alert(items[5]);
        series[0].data.push([
      Date.parse(x), parseFloat(items[5]) ]);
      }
    });
   
            options.series = series;
   
      // Create the chart
      var chart = new Highcharts.StockChart(options);
         })
  }

requestData()

      </script>


csv file:
Code: Select all
Datum;Uhrzeit;Position;Kurs;G/V;G/V kum.
03.01.2012;22:01:00;L;12397,38;0;0
06.01.2012;22:01:00;S;12359,92;-37,46;-37,46
10.01.2012;22:01:00;L;12462,47;-102,55;-140,01
12.01.2012;22:01:00;S;12471,02;8,55;-131,46
13.01.2012;22:01:00;L;12422,06;48,96;-82,5
17.01.2012;22:01:00;S;12482,07;60,01;-22,49
18.01.2012;22:01:00;L;12578,95;-96,88;-119,37
23.01.2012;22:01:00;S;12708,82;129,87;10,5
26.01.2012;22:01:00;L;12734,63;-25,81;-15,31
03.02.2012;22:01:00;L;12854,4;-148,99;11876,02
04.02.2012;22:01:00;L;12854,4;-148,99;11876,02
05.02.2012;22:01:00;L;12854,4;-148,99;11876,02
06.02.2012;22:01:00;L;12854,4;-148,99;11876,02
07.02.2012;22:01:00;S;12820,95;-33,45;11842,57
08.02.2012;22:01:00;L;12879,26;-34,13;11832,62
chrispo
 
Posts: 5
Joined: Mon Jan 30, 2012 2:30 pm

Re: date with no data, invisible

Postby hfrntt » Wed Feb 22, 2012 12:21 am

Sorry for late reply. After reading your question one more time I realized what you meant. The answer is quite easy and I hope you already solved it on your own. But if anyone need this - it's possible since highstock 1.1.3 using gapSize (http://www.highcharts.com/stock/ref/#pl ... s--gapSize) and ordinal axes (http://www.highcharts.com/stock/ref/#xAxis--ordinal)
Slawek Kolodziej
Highcharts support team
hfrntt
 
Posts: 6394
Joined: Mon Aug 30, 2010 10:41 am


Return to Highstock Usage

Who is online

Users browsing this forum: Google [Bot] and 1 guest