OpenWeather: add description in chart
This commit is contained in:
parent
240ace2ced
commit
cb5c6ccb22
|
@ -53,10 +53,11 @@ export default {
|
||||||
},
|
},
|
||||||
tooltips: {
|
tooltips: {
|
||||||
intersect: false,
|
intersect: false,
|
||||||
|
mode: 'index',
|
||||||
callbacks: {
|
callbacks: {
|
||||||
title(tooltipItem: any, myData: any) {
|
title(tooltipItems: any, myData: any) {
|
||||||
const item = myData.datasets[tooltipItem[0].datasetIndex].data[tooltipItem[0].index]
|
const item = myData.datasets[tooltipItems[0].datasetIndex].data[tooltipItems[0].index]
|
||||||
return moment(item.x || item.t).format('HH[h]')
|
return moment(item.x || item.t).format('HH[h]') + (item.d ? ` - ${item.d}` : '')
|
||||||
},
|
},
|
||||||
label(tooltipItem: any, myData: any) {
|
label(tooltipItem: any, myData: any) {
|
||||||
let label = myData.datasets[tooltipItem.datasetIndex].label || ''
|
let label = myData.datasets[tooltipItem.datasetIndex].label || ''
|
||||||
|
|
|
@ -44,6 +44,9 @@ interface Forecast {
|
||||||
rain?: {
|
rain?: {
|
||||||
'3h': number
|
'3h': number
|
||||||
}
|
}
|
||||||
|
weather: Array<{
|
||||||
|
description: string
|
||||||
|
}>,
|
||||||
}
|
}
|
||||||
|
|
||||||
const AUTH = { TOKEN: 'token' }
|
const AUTH = { TOKEN: 'token' }
|
||||||
|
@ -83,9 +86,9 @@ export default class OpenWeatherMap extends ConnectedService<object, object> {
|
||||||
borderWidth: 1,
|
borderWidth: 1,
|
||||||
fill: false,
|
fill: false,
|
||||||
data: fs.map(line => ({
|
data: fs.map(line => ({
|
||||||
x: line.dt * 1000, y: line.main.temp
|
x: line.dt * 1000, y: line.main.temp, d: line.weather[0].description
|
||||||
}))
|
}))
|
||||||
},{
|
}, {
|
||||||
type: 'bar',
|
type: 'bar',
|
||||||
label: 'Percipitation',
|
label: 'Percipitation',
|
||||||
yAxisID: 'y-axis-rain',
|
yAxisID: 'y-axis-rain',
|
||||||
|
|
Loading…
Reference in New Issue