mirror of
https://git.yoctoproject.org/poky
synced 2026-04-05 08:02:25 +02:00
- Add Apache echarts (https://echarts.apache.org/en/index.html) library to create build performance charts. - Restructure data to time and value array format so that it can be used by echarts. - This commit also converts test duration to minutes to map against the values axis. - Zoom is added to the line charts. (From OE-Core rev: 63c9321832aae79d20a4ddd199a4a1385f81de53) Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
77 lines
2.0 KiB
HTML
77 lines
2.0 KiB
HTML
<script type="module">
|
|
// Get raw data
|
|
const rawData = [
|
|
{% for sample in measurement.samples %}
|
|
[{{ sample.commit_num }}, {{ sample.mean.gv_value() }}, {{ sample.start_time }}],
|
|
{% endfor %}
|
|
];
|
|
|
|
const convertToMinute = (time) => {
|
|
return time[0]*60 + time[1] + time[2]/60 + time[3]/3600;
|
|
}
|
|
|
|
// Convert raw data to the format: [time, value]
|
|
const data = rawData.map(([commit, value, time]) => {
|
|
return [
|
|
new Date(time * 1000).getTime(), // The Date object takes values in milliseconds rather than seconds. So to use a Unix timestamp we have to multiply it by 1000.
|
|
Array.isArray(value) ? convertToMinute(value) : value // Assuming the array values are duration in the format [hours, minutes, seconds, milliseconds]
|
|
]
|
|
});
|
|
|
|
// Set chart options
|
|
const option = {
|
|
tooltip: {
|
|
trigger: 'axis',
|
|
position: function (pt) {
|
|
return [pt[0], '10%'];
|
|
},
|
|
valueFormatter: (value) => value.toFixed(2)
|
|
},
|
|
xAxis: {
|
|
type: 'time',
|
|
},
|
|
yAxis: {
|
|
name: '{{ measurement.value_type.quantity }}' == 'time' ? 'Duration (minutes)' : 'Disk size (MB)',
|
|
type: 'value',
|
|
min: function(value) {
|
|
return Math.round(value.min - 0.5);
|
|
},
|
|
max: function(value) {
|
|
return Math.round(value.max + 0.5);
|
|
}
|
|
},
|
|
dataZoom: [
|
|
{
|
|
type: 'inside',
|
|
start: 0,
|
|
end: 100
|
|
},
|
|
{
|
|
start: 0,
|
|
end: 100
|
|
}
|
|
],
|
|
series: [
|
|
{
|
|
name: '{{ measurement.value_type.quantity }}',
|
|
type: 'line',
|
|
smooth: true,
|
|
symbol: 'none',
|
|
data: data
|
|
}
|
|
]
|
|
};
|
|
|
|
// Draw chart
|
|
const chart_div = document.getElementById('{{ chart_elem_id }}');
|
|
const measurement_chart= echarts.init(chart_div, null, {
|
|
height: 320
|
|
});
|
|
// Change chart size with browser resize
|
|
window.addEventListener('resize', function() {
|
|
measurement_chart.resize();
|
|
});
|
|
measurement_chart.setOption(option);
|
|
</script>
|
|
|