Hi @mikhailvolkov ,
in my previous working version of the charts I was using this code, which works:
let wind;
data.series.map((s) => {
const time = s.fields.find((f) => f.name === 'Time').values;
const value = s.fields.find((f) => f.name === 'wind_speed').values;
const rotate = s.fields.find((f) => f.name === 'wind_direction').values;
/**
Set Wind from 3 arrays
*/
wind = time.map((id, index) => {
return {
symbolRotate: -rotate[index] - 180.0,
value: [time[index], value[index]]
};
});
});
/**
* Enable Data Zoom by default
*/
setTimeout(() => echartsInstance.dispatchAction({
type: 'takeGlobalCursor',
key: 'dataZoomSelect',
dataZoomSelectActive: false,
}), 500);
/**
* Update Time Range on Zoom
*/
echartsInstance.on('datazoom', function (params) {
const startValue = params.batch[0]?.startValue;
const endValue = params.batch[0]?.endValue;
locationService.partial({ from: startValue, to: endValue });
});
return {
backgroundColor: 'transparent',
tooltip: {
trigger: 'item',
formatter: function (params) {
let currtime = echarts.format.formatTime('dd-MM-yyyy hh:mm:ss', params.data.value[0]);
let speed = params.data.value[1].toFixed(3); // Format speed to two decimals
let direction = (-params.data.symbolRotate - 180.0).toFixed(1); // Format direction to two decimals
return `Time: ${currtime} <br/>
Speed: ${speed} kn<br/>
Direction: ${direction} °`;
}
},
textStyle: {
color: '#324148',
fontFamily: '"Poppins", sans-serif',
fontSize: 22,
fontWeight: 'bold'
},
legend: {
left: '0',
bottom: '0',
data: ['Current Speed & Angle'],
textStyle: {
color: 'rgba(128, 128, 128, .9)',
},
},
toolbox: {
feature: {
dataZoom: {
yAxisIndex: 'none',
icon: {
zoom: 'path://',
back: 'path://',
},
},
saveAsImage: {
name: 'Current speed & direction',
backgroundColor: 'white'
},
}
},
xAxis: {
type: 'time'
},
yAxis: {
type: 'value',
axisLabel: {
formatter: '{value} kn'
},
},
grid: {
left: '2%',
right: '2%',
top: '2%',
bottom: 24,
containLabel: true,
},
visualMap: {
orient: 'horizontal',
left: 'center',
min: 0,
max: 1.5,
text: ['strong', 'weak'],
dimension: 1,
inRange: {
color: ['#add8e6', '#00bfff', '#00008b']
}
},
series: [
{
data: wind,
type: 'line',
symbol: 'path://M31 24.7343L21.7917 24.7343V0L9.20826 0L9.20826 24.7343H0L15.5 45L31 24.7343Z',
symbolSize: 20,
areaStyle: {
opacity: 0.3,
},
lineStyle: {
width: 1
}
}
]
};
This does not work now with the Charts upgrade.
Could you please indicate how should I treat the data source and if I should use “Code” or “Visual” tab?
Appreciated.
Cheers