CARVIEW |
Select Language
HTTP/2 200
accept-ranges: bytes
access-control-allow-origin: *
age: 0
cache-control: max-age=600
content-encoding: gzip
content-type: text/html; charset=utf-8
date: Mon, 28 Jul 2025 20:15:45 GMT
etag: W/"687e6266-70b2"
expires: Mon, 28 Jul 2025 20:25:45 GMT
last-modified: Mon, 21 Jul 2025 15:53:10 GMT
server: Vercel
strict-transport-security: max-age=63072000
vary: Accept-Encoding
via: 1.1 varnish
x-cache: MISS
x-cache-hits: 0
x-fastly-request-id: c6cb9e3d6c752ad06d04fc07026bdc5d3bd74a19
x-github-request-id: 6287:E4D41:753D:93FA:6887DA6D
x-origin-cache: HIT
x-proxy-cache: MISS
x-robots-tag: index
x-served-by: cache-bom-vanm7210038-BOM
x-timer: S1753733746.611556,VS0,VE235
x-vercel-cache: MISS
x-vercel-id: bom1::55kx8-1753733745592-92bf1f9b13f3
content-length: 7760
Range slider and selector in JavaScript
Range Slider and Selector in JavaScript
How to add range sliders to a D3.js-based line or scatter chart. Examples of Range Sliders
Plotly Studio: Transform any dataset into an interactive data application in minutes with AI. Sign up for early access now.
var rawDataURL = 'https://raw.githubusercontent.com/plotly/datasets/master/2016-weather-data-seattle.csv';
var xField = 'Date';
var yField = 'Mean_TemperatureC';
var selectorOptions = {
buttons: [{
step: 'month',
stepmode: 'backward',
count: 1,
label: '1m'
}, {
step: 'month',
stepmode: 'backward',
count: 6,
label: '6m'
}, {
step: 'year',
stepmode: 'todate',
count: 1,
label: 'YTD'
}, {
step: 'year',
stepmode: 'backward',
count: 1,
label: '1y'
}, {
step: 'all',
}],
};
d3.csv(rawDataURL, function(err, rawData) {
if(err) throw err;
var data = prepData(rawData);
var layout = {
title: {
text: 'Time series with range slider and selectors'
},
xaxis: {
rangeselector: selectorOptions,
rangeslider: {}
},
yaxis: {
fixedrange: true
}
};
Plotly.newPlot('myDiv', data, layout);
});
function prepData(rawData) {
var x = [];
var y = [];
rawData.forEach(function(datum, i) {
x.push(new Date(datum[xField]));
y.push(datum[yField]);
});
return [{
mode: 'lines',
x: x,
y: y
}];
}
