Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <!DOCTYPE HTML>
<html>
<head>
 
</head>
<body>
  <div class="holder">
<div id="chartContainer" style="height: 300px; width: 100%;">
  </div>
       <div id="slider-range" style="width:100%;"></div><br/><br/>
  </div>
  

  
<script src="https://canvasjs.com/assets/script/canvasjs.min.js"></script> 
  <link type="text/css"  href="http://code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css" rel="stylesheet" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="http://code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
</body>
</html>
              
            
!

CSS

              
                #slider-range
{
  bottom:7px;
  position:absolute;
}
.holder
{
  position:relative;
}
.ui-slider-horizontal .ui-slider-handle {
    top: 0px;
    margin-left: -.6em;
}

.ui-slider .ui-slider-handle {
    position: absolute;
    z-index: 2;
    width: 1.2em;
    height: 18px;
    cursor: pointer;
    -ms-touch-action: none;
    touch-action: none;
} 
              
            
!

JS

              
                var sliding = 0;

var dps = [];
var dpss = [];
var dpsss = [];
    var current = 0;

window.onload = function () {



var chart = new CanvasJS.Chart("chartContainer", {
 
 
	title :{
		text: "Dynamic Spline Chart"
	},
	axisX:
	{
 	        viewportMinimum : 0,
	        viewportMinimum : 100,
    	crosshair: {
			enabled: true,
			snapToDataPoint: true
		}

	},
	axisY: {
		includeZero: false,
		 minimum: -500,
    maximum: 500,
	},
  axisY2: {
		includeZero: false
	},
	data: [{

		type: "stackedColumn",
		markerSize: 0,
		dataPoints: dps 
	},
          {
 
		type: "stackedColumn",
		markerSize: 0,
		dataPoints: dpss 
	},
          {
    axisYType: "secondary",

		type: "line",
		markerSize: 0,
		dataPoints: dpsss 
	}]
});

var xVal = 0;
var yVal = 100;
var updateInterval = 1;
var dataLength = 240; // number of dataPoints visible at any point

var updateChart = function (count) {
	count = count || 1;
	// count is number of times loop runs to generate random dataPoints.
	for (var j = 0; j < count; j++) {	
		yVal = yVal + Math.round(5 + Math.random() *(-5-5));
				yValx = yVal + Math.round(12 + Math.random() *(-5-5));
    
 var lab = curTime();                     
		dps.push({
			x: lab,
			y: yVal
		}); 
      dpss.push({
			x: lab,
			y: -yValx
		});
      dpsss.push({
 
			x: lab,
			y: yVal-22
		});
		xVal++;
	}
	if(sliding)
    {
                 var max = current; 

    }
  else 
    {
             var max = dps.length-100; 

    }
  chart.options.axisX.viewportMinimum = max;
		            chart.options.axisX.viewportMaximum = dps.length;


	chart.render();
};

updateChart(dataLength); 
setInterval(function(){ updateChart() }, updateInterval); 

}


$("#slider-range").slider({
        range: "max",
        min:0,
        value:10,
        slide: function (event, ui) {
            current = ui.value;
          console.log(current);
            $( "#slider-range" ).slider( "option", "max", dps[dps.length-1].x );
        	$( "#slider-range" ).slider(  "value", current );
       		$( "#slider-range" ).slider( "option", "min", 0 );
        }
    });

$("#slider-range").slider({
  start: function( event, ui ) {
   sliding = 1; 
  }
});

$("#slider-range").on( "slidestop", function( event, ui ) {
     sliding = 0; 

 console.log("hxxxi"); 
} );



function curTime() {
    var d = new Date();
    var x = document.getElementById("demo");
    var h = addZero(d.getHours(), 2);
    var m = addZero(d.getMinutes(), 2);
    var s = addZero(d.getSeconds(), 2);
    var ms = addZero(d.getMilliseconds(), 3);
    var x = h + ":" + m + ":" + s + ":" + ms;
    return x;
}
function addZero(x,n) {
    while (x.toString().length < n) {
        x = "0" + x;
    }
    return x;
}
              
            
!
999px

Console