Skip to content

OpenVINO™ is an open source toolkit for optimizing and deploying AI inference

[DOCS] Port changes for Make One Legend to master (#27877)

Andrzej Kopytko340a3d4a1357
diff --git a/docs/sphinx_setup/_static/css/custom.css b/docs/sphinx_setup/_static/css/custom.css
index f922069c45e..de8a05732a4 100644
--- a/docs/sphinx_setup/_static/css/custom.css
+++ b/docs/sphinx_setup/_static/css/custom.css
@@ -923,6 +923,8 @@ h5 {
position: relative;
bottom: -16px;
left: 0;
+ margin-left: auto;
+ padding-right: 30px;
}
.modal-footer-content {
diff --git a/docs/sphinx_setup/_static/html/modal.html b/docs/sphinx_setup/_static/html/modal.html
index 38eb673824f..e7bcc1c1c16 100644
--- a/docs/sphinx_setup/_static/html/modal.html
+++ b/docs/sphinx_setup/_static/html/modal.html
@@ -87,6 +87,6 @@
</div>
<div class="chart-placeholder"></div>
</section>
- <div class="modal-footer">
- </div>
+ <div class="modal-line-divider"></div>
+ <div class="modal-footer" id="modal-footer"></div>
</div>
\ No newline at end of file
diff --git a/docs/sphinx_setup/_static/html/modalLLM.html b/docs/sphinx_setup/_static/html/modalLLM.html
index 37b569d0bd4..e8535c87f16 100644
--- a/docs/sphinx_setup/_static/html/modalLLM.html
+++ b/docs/sphinx_setup/_static/html/modalLLM.html
@@ -87,6 +87,6 @@
</div>
<div class="chart-placeholder"></div>
</section>
- <div class="modal-footer">
- </div>
+ <div class="modal-line-divider"></div>
+ <div class="modal-footer" id="modal-footer"></div>
</div>
\ No newline at end of file
diff --git a/docs/sphinx_setup/_static/js/graphs.js b/docs/sphinx_setup/_static/js/graphs.js
index 697911bad94..04e34d6c2fe 100644
--- a/docs/sphinx_setup/_static/js/graphs.js
+++ b/docs/sphinx_setup/_static/js/graphs.js
@@ -60,8 +60,8 @@ class Filter {
// param: GraphData[], clientPlatforms[]
static BySortPlatforms(graphDataArr, platformsArr) {
return graphDataArr
- .filter((data) => platformsArr.includes(data.Platform))
- .sort((a, b) => a.Platform.localeCompare(b.Platform));
+ .filter((data) => platformsArr.includes(data.Platform))
+ .sort((a, b) => a.Platform.localeCompare(b.Platform));
//sort is necessary
}
}
@@ -145,8 +145,8 @@ class Graph {
array.push([obj])
}
})
- return array;
+ return array;
}
// this returns an object that is used to ender the chart
@@ -283,13 +283,13 @@ $(document).ready(function () {
const models = networkModels.map((networkModel) => createCheckMark(networkModel, 'networkmodel'));
modal.find('.models-column').append(models);
- const selectAllModelsButton = createCheckMark('', 'networkmodel', false , false);
+ const selectAllModelsButton = createCheckMark('', 'networkmodel', false, false);
modal.find('.models-selectall').append(selectAllModelsButton);
- const selectAllPlatformsButton = createCheckMark('', 'platform', false , false);
+ const selectAllPlatformsButton = createCheckMark('', 'platform', false, false);
modal.find('.platforms-selectall').append(selectAllPlatformsButton);
- const precisions = Modal.getPrecisionsLabels(graph).map((precision) => createCheckMark(precision, 'precision', false , false));
+ const precisions = Modal.getPrecisionsLabels(graph).map((precision) => createCheckMark(precision, 'precision', false, false));
modal.find('.precisions-column').append(precisions);
selectAllCheckboxes(precisions);
@@ -304,7 +304,7 @@ $(document).ready(function () {
modal.find('#modal-display-graphs').hide();
modal.find('.ietype-column input').first().prop('checked', true);
- const kpiLabels = Filter.getParameters(graph).map((parameter) => createCheckMark(parameter, 'kpi', false , true));
+ const kpiLabels = Filter.getParameters(graph).map((parameter) => createCheckMark(parameter, 'kpi', false, true));
modal.find('.kpi-column').append(kpiLabels);
$('body').prepend(modal);
@@ -511,6 +511,7 @@ $(document).ready(function () {
listContainer.style.margin = 0;
listContainer.style.padding = 0;
listContainer.style.paddingLeft = '0px';
+ listContainer.style.float = "right";
legendContainer.appendChild(listContainer);
}
@@ -521,57 +522,55 @@ $(document).ready(function () {
const htmlLegendPlugin = {
id: 'htmlLegend',
afterUpdate(chart, args, options) {
-
+ charts = [...new Set([...charts, ...[chart]])];
const ul = getOrCreateLegendList(chart, chart.options.plugins.htmlLegend.containerID);
-
// Remove old legend items
while (ul.firstChild) {
ul.firstChild.remove();
}
- const items = chart.legend.legendItems;
+ const items = chart.options.plugins.legend.labels.generateLabels(chart);
items.forEach(item => {
const li = document.createElement('li');
li.style.alignItems = 'center';
li.style.display = 'block';
li.style.flexDirection = 'column';
- li.style.marginLeft = '4px';
-
+ li.style.marginLeft = '6px';
+ li.style.cursor = "pointer";
+ li.style.fontSize = '0.6rem';
+ li.style.textDecoration = item.hidden ? 'line-through' : '';
li.onclick = () => {
- chart.toggleDataVisibility(item.index);
- chart.update();
+ charts.forEach((chartItem) => {
+ chartItem.setDatasetVisibility(item.datasetIndex, !chartItem.isDatasetVisible(item.datasetIndex));
+ chartItem.update();
+ })
};
-
- // Color box
+
const boxSpan = document.createElement('span');
boxSpan.style.background = item.fillStyle;
boxSpan.style.borderColor = item.strokeStyle;
- boxSpan.style.borderWidth = item.lineWidth + 'px';
boxSpan.style.display = 'inline-block';
boxSpan.style.height = '10px';
boxSpan.style.marginRight = '4px';
boxSpan.style.width = '30px';
- // Text
- const textContainer = document.createElement('p');
- textContainer.style.color = '#666';
- textContainer.style.margin = 0;
- textContainer.style.padding = 0;
- textContainer.style.fontSize = '0.6rem';
- textContainer.style.marginLeft = '3px';
- textContainer.style.textDecoration = item.hidden ? 'line-through' : '';
+ const textSpan = document.createElement('span');
+ textSpan.style.bottom = '1px'
+ textSpan.style.position = 'relative'
+ textSpan.style.fontSize = '0.6rem';
+ textSpan.style.textDecoration = item.hidden ? 'line-through' : '';
const text = document.createTextNode(item.text);
- textContainer.appendChild(text);
+ textSpan.appendChild(text);
li.appendChild(boxSpan);
- li.appendChild(textContainer);
+ li.appendChild(textSpan);
ul.appendChild(li);
});
}
};
- function getChartOptionsByEngines(containerId, allowedAxisIDs) {
+ function getChartOptionsByEngines(allowedAxisIDs) {
const axisConfigs = {
x: {
title: { display: true, text: 'Request Rate' }
@@ -602,11 +601,11 @@ $(document).ready(function () {
}, {}),
plugins: {
legend: { display: false },
- htmlLegend: { containerID: containerId }
+ htmlLegend: { containerID: 'modal-footer' }
}
};
}
- function getChartOptions(title, containerId) {
+ function getChartOptions(title) {
return {
responsive: true,
indexAxis: 'y',
@@ -633,7 +632,7 @@ $(document).ready(function () {
display: false
},
htmlLegend: {
- containerID: containerId,
+ containerID: 'modal-footer',
}
}
}
@@ -838,7 +837,7 @@ $(document).ready(function () {
new Chart(context, {
type: 'bar',
data: getChartData(labels, datasets),
- options: getChartOptions(chartTitle, containerId),
+ options: getChartOptions(chartTitle),
plugins: [htmlLegendPlugin]
});
});
@@ -858,9 +857,9 @@ $(document).ready(function () {
})
}
}
-
+ var charts = [];
function processMetricByEngines(labels, datasets, container, widthClass, id) {
- var heightRatio = (80 + (labels.length * 55));
+ var heightRatio = (30 + (labels.length * 55));
var chart = $('<div>');
const containerId = `legend-container-${id}`;
const legend = $(`<div id="${containerId}">`);
@@ -894,8 +893,7 @@ $(document).ready(function () {
backgroundColor: precision.color,
yAxisID: precision.label === "Throughput" ? 'y' : 'y1',
fill: false
- }
- )
+ })
})
})
@@ -914,9 +912,10 @@ $(document).ready(function () {
labels: labels,
datasets: graphDatas
},
- options: getChartOptionsByEngines(containerId, allowedAxisIDs),
+ options: getChartOptionsByEngines(allowedAxisIDs),
plugins: [htmlLegendPlugin]
});
+
});
}
diff --git a/docs/sphinx_setup/_templates/layout.html b/docs/sphinx_setup/_templates/layout.html
index 7f873c679c2..0d2331b2c83 100644
--- a/docs/sphinx_setup/_templates/layout.html
+++ b/docs/sphinx_setup/_templates/layout.html
@@ -11,7 +11,7 @@
<link rel="stylesheet" href="{{ pathto('_static/css/banner.css', 1) }}" type="text/css" />
<link href="https://cdn.datatables.net/v/dt/jq-3.7.0/dt-2.0.8/b-3.0.2/b-colvis-3.0.2/b-print-3.0.2/datatables.min.css" rel="stylesheet">
<link rel="stylesheet" href="{{ pathto('_static/css/coveo_custom.css', 1) }}" type="text/css" />
-<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/chart.umd.min.js"></script>
+<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/chart.umd.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/PapaParse/5.3.1/papaparse.min.js"></script>
<script src="{{ pathto('_static/js/viewer.min.js', 1) }}"></script>
<script src="/assets/versions_raw.js"></script>