JSFiddle - React, Tailwind, and code Playground
by Piyush B
HTML
<script src="https://code.highcharts.com/highcharts.js"></script>
<script src="https://code.highcharts.com/modules/exporting.js"></script>
<script src="https://code.highcharts.com/modules/export-data.js"></script>
<script src="https://code.highcharts.com/modules/accessibility.js"></script>
<figure class="highcharts-figure">
<div id="container"></div>
<p class="highcharts-description">
Scatter charts are often used to visualize the relationships
between data in two dimensions. This chart is visualizing
height and weight by gender, showing a clear trend where men
are on average taller and heavier than women.
</p>
</figure>
CSS
.highcharts-figure,
.highcharts-data-table table {
min-width: 360px;
max-width: 800px;
margin: 1em auto;
}
.highcharts-data-table table {
font-family: Verdana, sans-serif;
border-collapse: collapse;
border: 1px solid #ebebeb;
margin: 10px auto;
text-align: center;
width: 100%;
max-width: 500px;
}
.highcharts-data-table caption {
padding: 1em 0;
font-size: 1.2em;
color: #555;
}
.highcharts-data-table th {
font-weight: 600;
padding: 0.5em;
}
.highcharts-data-table td,
.highcharts-data-table th,
.highcharts-data-table caption {
padding: 0.5em;
}
.highcharts-data-table thead tr,
.highcharts-data-table tr:nth-child(even) {
background: #f8f8f8;
}
.highcharts-data-table tr:hover {
background: #f1f7ff;
}
JavaScript
var st =new Date("2014-07-09T12:30:41Z")
var st2 =st.getTime()/1000
var st3 =new Date("2014-07-10T13:30:41Z")
var st4 =new Date("2014-07-14T13:30:41Z")
var st5 =new Date("2014-07-18T13:30:41Z")
var st6 =new Date("2014-07-25T13:30:41Z")
var st7 =new Date("2014-07-26T13:30:41Z")
var st8 =new Date("2014-07-25T13:30:41Z")
var st9 =new Date("2014-07-26T13:30:41Z")
var st10 =new Date("2014-07-27T13:30:41Z")
var st11 =new Date("2014-07-29T13:30:41Z")
var st12 =new Date("2014-07-31T13:30:41Z")
var en =new Date("2014-07-30T13:30:41Z")
var a = st.getTime()
var b= en.getTime()
var arrob=[]
var myObject = new Object();
myObject.x = st;
myObject.y = 100;
arrob.push(myObject)
var myObject1 = new Object();
myObject1.x = st3;
myObject1.y = 110;
arrob.push(myObject1)
var myObject2 = new Object();
myObject1.x = st4;
myObject1.y = 110;
arrob.push(myObject2)
var myString = JSON.stringify(myObject);
var asd = [{x:st,y:100},{x:st2, y:200}]
//alert(asd)
var minutes = parseInt(Math.abs(st.getTime() - en.getTime()) / (1000 * 60) % 60);
//alert(minutes)
var c=st-en
//alert(c/60000)
Highcharts.chart('container', {
chart: {
type: 'scatter',
zoomType: 'xy'
},
title: {
text: 'Height Versus Weight of 507 Individuals by Gender'
},
subtitle: {
text: 'Source: Heinz 2003'
},
xAxis: {
title: {
enabled: true,
text: 'PR Creation'
},
startOnTick: true,
endOnTick: true,
showLastLabel: true,
type: 'datetime',
dateTimeLabelFormats: {
second: '%Y-%m-%d<br/>%H:%M:%S',
minute: '%Y-%m-%d<br/>%H:%M',
hour: '%Y-%m-%d<br/>%H:%M',
day: '%Y<br/>%m-%d',
week: '%Y<br/>%m-%d',
month: '%Y-%m',
year: '%Y'
}
},
yAxis: {
title: {
text: 'duration'
},
type: 'datetime', //y-axis will be in milliseconds
dateTimeLabelFormats: {
minute: '%H:%M'
}
},
legend: {
layout: 'vertical',
...