Skip to content

Commit 3923c95

Browse files
committed
Refactor Jenkinsfile to remove unnecessary commands and improve HTML report handling. Update index.js to add cumulative histogram chart for enhanced data visualization.
1 parent 597d9c4 commit 3923c95

2 files changed

Lines changed: 76 additions & 6 deletions

File tree

Jenkinsfile

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,8 @@ pipeline {
3131
post {
3232
always {
3333
script {
34-
// Проверяем, существует ли HTML файл
35-
sh 'ls -la'
3634
if (fileExists('time_diff_histogram.html')) {
37-
// Архивируем HTML файл как артефакт
3835
archiveArtifacts artifacts: 'time_diff_histogram.html', fingerprint: true
39-
40-
// Публикуем HTML отчёт для просмотра в Jenkins
4136
publishHTML([
4237
allowMissing: false,
4338
alwaysLinkToLastBuild: true,
@@ -47,7 +42,6 @@ pipeline {
4742
reportName: 'TimeDiff Histogram Report',
4843
reportTitles: ''
4944
])
50-
5145
echo 'TimeDiff histogram generated and published successfully'
5246
} else {
5347
echo 'TimeDiff histogram file not found - skipping artifact archiving and HTML report publishing'

index.js

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -608,6 +608,7 @@ function generateInteractiveHistogram(timeDiffStats, title, filename) {
608608
609609
<div id="histogram" class="plot-container"></div>
610610
<div id="boxplot" class="plot-container"></div>
611+
<div id="cumulative" class="plot-container"></div>
611612
</div>
612613
613614
<script>
@@ -693,9 +694,84 @@ function generateInteractiveHistogram(timeDiffStats, title, filename) {
693694
margin: { t: 50, b: 50, l: 50, r: 50 }
694695
};
695696
697+
// Создаем накопительный график по диапазонам дней
698+
function createCumulativeChart() {
699+
// Сортируем данные по возрастанию
700+
const sortedData = [...data].sort((a, b) => a - b);
701+
702+
// Создаем диапазоны (например, по 10 дней)
703+
const rangeSize = 10;
704+
const maxValue = Math.max(...sortedData);
705+
const ranges = [];
706+
const cumulativeCounts = [];
707+
const labels = [];
708+
709+
let cumulativeSum = 0;
710+
711+
for (let i = rangeSize; i <= maxValue + rangeSize; i += rangeSize) {
712+
const rangeStart = i - rangeSize;
713+
const rangeEnd = i;
714+
715+
// Считаем количество элементов в текущем диапазоне
716+
const countInRange = sortedData.filter(val => val >= rangeStart && val < rangeEnd).length;
717+
718+
// Добавляем к накопительной сумме
719+
cumulativeSum += countInRange;
720+
721+
ranges.push(i);
722+
cumulativeCounts.push(cumulativeSum);
723+
labels.push(\`\${rangeStart.toFixed(0)}-\${rangeEnd.toFixed(0)} days\`);
724+
}
725+
726+
const cumulativeTrace = {
727+
x: ranges,
728+
y: cumulativeCounts,
729+
type: 'scatter',
730+
mode: 'lines+markers',
731+
name: 'Cumulative Sum',
732+
line: {
733+
color: 'rgba(31, 119, 180, 1)',
734+
width: 3
735+
},
736+
marker: {
737+
size: 8,
738+
color: 'rgba(31, 119, 180, 0.8)'
739+
},
740+
hovertemplate: 'Range: up to %{x} days<br>Cumulative Count: %{y}<br><extra></extra>',
741+
text: labels,
742+
hoverinfo: 'text+y'
743+
};
744+
745+
const cumulativeLayout = {
746+
title: {
747+
text: 'Cumulative Distribution by Day Ranges',
748+
font: { size: 18 }
749+
},
750+
xaxis: {
751+
title: 'Day Range (up to)',
752+
showgrid: true,
753+
gridcolor: 'rgba(128,128,128,0.2)'
754+
},
755+
yaxis: {
756+
title: 'Cumulative Count of Records',
757+
showgrid: true,
758+
gridcolor: 'rgba(128,128,128,0.2)'
759+
},
760+
plot_bgcolor: 'rgba(0,0,0,0)',
761+
paper_bgcolor: 'rgba(0,0,0,0)',
762+
showlegend: true,
763+
margin: { t: 50, b: 50, l: 50, r: 50 }
764+
};
765+
766+
return { trace: cumulativeTrace, layout: cumulativeLayout };
767+
}
768+
769+
const cumulativeChart = createCumulativeChart();
770+
696771
// Создаем графики
697772
Plotly.newPlot('histogram', [histogramTrace], histogramLayout, histogramConfig);
698773
Plotly.newPlot('boxplot', [boxplotTrace], boxplotLayout, histogramConfig);
774+
Plotly.newPlot('cumulative', [cumulativeChart.trace], cumulativeChart.layout, histogramConfig);
699775
</script>
700776
</body>
701777
</html>`;

0 commit comments

Comments
 (0)