i am using angular 2 highchart and i want to show 'spline' highchart with date on x axis and time on y axis and my chart lines going as linear, its because i have same datetime ticks for both axis. i want to segregate those axis as Date and Time, how can i do that
here is my sample data as below
[{"x":1517192498650,"y":1517192498650,"name":"GS_20180129_DailyTrades_Finception"},{"x":1517190450740,"y":1517190450740,"name":"GS_20180129_DailyTrades_Finception"},{"x":1517105975550,"y":1517105975550,"name":"GS_20180128_DailyTrades_Finception"},{"x":1517103307507,"y":1517103307507,"name":"GS_20180128_DailyTrades_Finception"},{"x":1517017629587,"y":1517017629587,"name":"GS_20180127_DailyTrades_Finception"},{"x":1517017613657,"y":1517017613657,"name":"GS_20180127_DailyTrades_Finception"},{"x":1516932898280,"y":1516932898280,"name":"GS_20180126_DailyTrades_Finception"}]
Here is my data manipulation code in typescript
static PrepareFileTransactionsForDateTimeChart(fileTransactions: Array<FileTransactionViewModel>) {
const formattedFileTransactions = new Array<any>();
fileTransactions.forEach((_fileTransaction: FileTransactionViewModel) => {
const data = {
x: moment(_fileTransaction.DateTime).valueOf(),
y: moment(_fileTransaction.DateTime).valueOf(),
// x: moment(moment(_fileTransaction.DateTime).format('DD-MM-YYYY') + ' 12:00:00').valueOf(),
// y: moment('01-01-2018 ' + moment(_fileTransaction.DateTime).format('HH:MM:SS')).valueOf(),
name: _fileTransaction.FileName
};
formattedFileTransactions.push(data);
});
return formattedFileTransactions;
}
and at last here is my highchart code where i am plotting the data
async AppendChartData(data: any) {
this.options = {
chart: {
type: 'spline'
},
title: {
text: 'File transactions overview'
},
subtitle: {
text: ''
},
xAxis: {
type: 'datetime',
title: {
text: 'Date'
},
labels: {
format: '{value:%e-%b-%Y}'
},
},
yAxis: {
type: 'datetime',
title: {
text: 'Time'
},
labels: {
format: '{value:%H:%M:%S}'
},
},
tooltip: {
headerFormat: '',
pointFormat: '<b>{point.name}: </b> <br><br> {point.x:%e-%b-%Y} {point.y:%H:%M:%S}',
followPointer: true,
enabled: true,
shadow: false
},
plotOptions: {
spline: {
lineWidth: 4,
states: {
hover: {
lineWidth: 5
}
},
marker: {
enabled: false
},
}
},
series: [{
name: 'File Transaction',
data: data
}]
};
}
and my data is plotting like in image below enter image description here
please let me know what will be the good approach to do so.