mettre les bouton d'export et d'impression sous le graphique et faire un autre graphique qui fait le classement d'importance des sous-catégories en fonction de toutes les semaines répertoriées - Initial Deployment
Browse filesFiles changed (2)
- README.md+7-5
- index.html+712-19
12345678910---title: Pic4emoji: 🔥colorFrom: purplecolorTo: yellowsdk: staticpinned: false---Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference123456789101112---title: pic4emoji: 🐳colorFrom: yellowcolorTo: pinksdk: staticpinned: falsetags:- deepsite---Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
12345678910111213141516171819<!doctype html><html><head><meta charset="utf-8" /><meta name="viewport" content="width=device-width" /><title>My static Space</title><link rel="stylesheet" href="style.css" /></head><body><div class="card"><h1>Welcome to your static Space!</h1><p>You can modify this app directly by editing <i>index.html</i> in the Files and versions tab.</p><p>Also don't forget to check the<a href="https://huggingface.co/docs/hub/spaces" target="_blank">Spaces documentation</a>.</p></div></body></html>123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712<!DOCTYPE html><html lang="fr"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>Classement des sous-catégories PIC</title><script src="https://cdn.tailwindcss.com"></script><script src="https://cdn.jsdelivr.net/npm/chart.js"></script><style>.block {transition: all 0.3s ease;cursor: grab;}.block:active {cursor: grabbing;}.block.dragging {opacity: 0.5;transform: scale(1.02);box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);}.placeholder {border: 2px dashed #6366f1;background-color: #e0e7ff;height: 60px;opacity: 0.8;}.block.selected {background-color: #e0e7ff;border: 1px solid #6366f1;}</style></head><body class="bg-gray-50 min-h-screen"><div class="container mx-auto px-4 py-8"><h1 class="text-3xl font-bold text-center text-indigo-700 mb-2">Classement des sous-catégories PIC</h1><p class="text-center text-gray-600 mb-8">Empilez les blocs pour créer votre classement hebdomadaire</p><div class="grid grid-cols-1 lg:grid-cols-2 gap-8"><!-- Zone de classement --><div class="bg-white p-6 rounded-lg shadow-md"><h2 class="text-xl font-semibold text-indigo-600 mb-4">Votre classement</h2><div class="flex justify-between mb-4"><div class="flex items-center space-x-2"><span class="text-sm font-medium text-gray-500">Semaine :</span><select id="week-selector" class="border rounded px-2 py-1 text-sm"><!-- Options seront ajoutées dynamiquement --></select></div><div class="flex space-x-2"><button id="save-btn" class="bg-indigo-600 text-white px-4 py-1 rounded text-sm hover:bg-indigo-700 transition">Enregistrer</button><button id="reset-btn" class="bg-red-600 text-white px-4 py-1 rounded text-sm hover:bg-red-700 transition">Réinitialiser</button></div></div><div id="ranking-container" class="space-y-2 mb-4"><!-- Les blocs seront ajoutés ici dynamiquement --></div><div id="placeholder" class="placeholder rounded flex items-center justify-center hidden"><span class="text-gray-500">Déposez ici pour ajouter</span></div></div><!-- Graphique d'évolution --><div class="bg-white p-6 rounded-lg shadow-md"><h2 class="text-xl font-semibold text-indigo-600 mb-4">Évolution du classement</h2><div class="h-64"><canvas id="ranking-chart"></canvas></div><div class="mt-4 text-sm text-gray-500"><p>Ce graphique montre l'évolution des positions de chaque catégorie au fil des semaines.</p></div><!-- Nouveau graphique d'importance globale --><h2 class="text-xl font-semibold text-indigo-600 mb-4 mt-8">Classement d'importance global</h2><div class="h-64"><canvas id="importance-chart"></canvas></div><div class="mt-4 text-sm text-gray-500"><p>Ce graphique montre le classement moyen de chaque catégorie sur toutes les semaines.</p></div><!-- Boutons d'export/import déplacés ici --><div class="flex justify-center space-x-4 mt-6"><button id="export-btn" class="bg-green-600 text-white px-4 py-2 rounded hover:bg-green-700 transition">Exporter données</button><button id="import-btn" class="bg-blue-600 text-white px-4 py-2 rounded hover:bg-blue-700 transition">Importer données</button></div></div></div></div><script>document.addEventListener('DOMContentLoaded', function() {// Catégories PICconst categories = ['Primo-info','Conseil','Protection contre la discrimination','Langue','Petite enfance','Employabilité','Interprétariat','Vivre-ensemble'];// État de l'applicationlet state = {currentWeek: 1,rankings: {},draggedItem: null};// Éléments DOMconst rankingContainer = document.getElementById('ranking-container');const placeholder = document.getElementById('placeholder');const weekSelector = document.getElementById('week-selector');const saveBtn = document.getElementById('save-btn');const chartCtx = document.getElementById('ranking-chart').getContext('2d');const importanceCtx = document.getElementById('importance-chart').getContext('2d');let rankingChart = null;let importanceChart = null;// Initialisationinit();function initImportanceChart() {const weeks = Object.keys(state.rankings).sort((a, b) => a - b);const categoryScores = {};// Calculer le score moyen pour chaque catégoriecategories.forEach(category => {let totalScore = 0;let count = 0;weeks.forEach(week => {const ranking = state.rankings[week];const position = ranking.indexOf(category) + 1;totalScore += position;count++;});categoryScores[category] = totalScore / count;});// Trier les catégories par score moyen (le plus bas en premier)const sortedCategories = [...categories].sort((a, b) => categoryScores[a] - categoryScores[b]);const sortedScores = sortedCategories.map(cat => categoryScores[cat]);if (importanceChart) {importanceChart.destroy();}importanceChart = new Chart(importanceCtx, {type: 'bar',data: {labels: sortedCategories,datasets: [{label: 'Score moyen (plus bas = mieux)',data: sortedScores,backgroundColor: '#6366f1',borderColor: '#4f46e5',borderWidth: 1}]},options: {responsive: true,maintainAspectRatio: false,indexAxis: 'y',scales: {x: {beginAtZero: true,title: {display: true,text: 'Position moyenne'}}},plugins: {tooltip: {callbacks: {label: function(context) {return `Position moyenne: ${context.raw.toFixed(2)}`;}}}}}});}function init() {// Charger les données depuis le localStorageloadData();// Initialiser le sélecteur de semaineinitWeekSelector();// Afficher les blocs pour la semaine couranterenderBlocks();// Initialiser les graphiquesinitCharts();// Écouteurs d'événementssetupEventListeners();}function loadData() {const savedData = localStorage.getItem('picRankings');if (savedData) {state.rankings = JSON.parse(savedData);// Trouver la dernière semaine enregistréeconst weeks = Object.keys(state.rankings).map(Number);if (weeks.length > 0) {state.currentWeek = Math.max(...weeks);}} else {// Premier chargement - initialiser avec la semaine 1state.rankings = {1: [...categories]};}}function saveData() {localStorage.setItem('picRankings', JSON.stringify(state.rankings));}function initWeekSelector() {weekSelector.innerHTML = '';const weeks = Object.keys(state.rankings).sort((a, b) => a - b);if (weeks.length === 0) {const option = document.createElement('option');option.value = '1';option.textContent = 'Semaine 1';weekSelector.appendChild(option);return;}weeks.forEach(week => {const option = document.createElement('option');option.value = week;option.textContent = `Semaine ${week}`;option.selected = week == state.currentWeek;weekSelector.appendChild(option);});// Ajouter une option pour une nouvelle semaineconst nextWeek = Math.max(...weeks.map(Number)) + 1;const newOption = document.createElement('option');newOption.value = nextWeek;newOption.textContent = `Nouvelle semaine (${nextWeek})`;weekSelector.appendChild(newOption);}function renderBlocks() {rankingContainer.innerHTML = '';const currentRanking = state.rankings[state.currentWeek] || [...categories];currentRanking.forEach((category, index) => {const block = createBlock(category, index + 1);rankingContainer.appendChild(block);});}function createBlock(category, position) {const block = document.createElement('div');block.className = 'block bg-white border border-gray-200 rounded p-4 shadow-sm flex items-center justify-between';block.draggable = true;block.dataset.category = category;// Drag eventsblock.addEventListener('dragstart', handleDragStart);block.addEventListener('dragend', handleDragEnd);block.innerHTML = `<div class="flex items-center"><span class="bg-indigo-100 text-indigo-800 rounded-full w-6 h-6 flex items-center justify-center text-xs font-semibold mr-3">${position}</span><span class="font-medium text-gray-700">${category}</span></div><svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5 text-gray-400" fill="none" viewBox="0 0 24 24" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 8h16M4 16h16" /></svg>`;return block;}function initCharts() {initRankingChart();initImportanceChart();}function initRankingChart() {const weeks = Object.keys(state.rankings).sort((a, b) => a - b);const datasets = [];categories.forEach(category => {const data = weeks.map(week => {const ranking = state.rankings[week];const position = ranking.indexOf(category) + 1;return position;});// Couleur aléatoire pour chaque catégorieconst color = getRandomColor();datasets.push({label: category,data: data,borderColor: color,backgroundColor: color,tension: 0.3,fill: false});});if (rankingChart) {rankingChart.destroy();}if (rankingChart) {rankingChart.destroy();}rankingChart = new Chart(chartCtx, {type: 'line',data: {labels: weeks.map(week => `Semaine ${week}`),datasets: datasets},options: {responsive: true,maintainAspectRatio: false,scales: {y: {reverse: true,beginAtZero: false,min: 1,max: categories.length,title: {display: true,text: 'Position'},ticks: {stepSize: 1}},x: {title: {display: true,text: 'Semaine'}}},plugins: {tooltip: {callbacks: {label: function(context) {return `${context.dataset.label}: ${context.raw}ème position`;}}}}}});}function getRandomColor() {const letters = '0123456789ABCDEF';let color = '#';for (let i = 0; i < 6; i++) {color += letters[Math.floor(Math.random() * 16)];}return color;}function handleDragStart(e) {const selectedBlocks = document.querySelectorAll('.block.selected');// If clicking on a non-selected block while others are selected, prevent dragif (selectedBlocks.length > 0 && !this.classList.contains('selected')) {e.preventDefault();return;}// Toggle selection if not shift-clickingif (!e.shiftKey) {document.querySelectorAll('.block.selected').forEach(block => {block.classList.remove('selected', 'bg-indigo-50');});this.classList.add('selected', 'bg-indigo-50');}// Get all selected blocks including this oneconst currentSelected = document.querySelectorAll('.block.selected');if (currentSelected.length > 1) {state.draggedItems = Array.from(currentSelected);state.draggedItems.forEach(item => {item.classList.add('dragging');item.style.opacity = '0.5';});} else {this.classList.add('dragging');state.draggedItem = this;}e.dataTransfer.effectAllowed = 'move';placeholder.classList.remove('hidden');}function handleDragEnd() {const items = state.draggedItems || [state.draggedItem];items.forEach(item => {if (item) {item.classList.remove('dragging');item.style.opacity = '';}});placeholder.classList.add('hidden');state.draggedItem = null;state.draggedItems = null;}function setupEventListeners() {// Bouton d'exportdocument.getElementById('export-btn').addEventListener('click', () => {const dataStr = JSON.stringify(state.rankings, null, 2);const dataUri = 'data:application/json;charset=utf-8,'+ encodeURIComponent(dataStr);const exportFileDefaultName = `pic-classement-export-${new Date().toISOString().slice(0,10)}.json`;const linkElement = document.createElement('a');linkElement.setAttribute('href', dataUri);linkElement.setAttribute('download', exportFileDefaultName);linkElement.click();});// Bouton d'importdocument.getElementById('import-btn').addEventListener('click', () => {const input = document.createElement('input');input.type = 'file';input.accept = '.json';input.onchange = e => {const file = e.target.files[0];const reader = new FileReader();reader.readAsText(file,'UTF-8');reader.onload = readerEvent => {try {const content = JSON.parse(readerEvent.target.result);state.rankings = content;saveData();renderBlocks();initWeekSelector();initChart();// Afficher un message de confirmationconst notification = document.createElement('div');notification.className = 'fixed bottom-4 right-4 bg-green-500 text-white px-4 py-2 rounded shadow-lg';notification.textContent = 'Données importées avec succès!';document.body.appendChild(notification);setTimeout(() => {notification.classList.add('opacity-0', 'transition-opacity', 'duration-300');setTimeout(() => notification.remove(), 300);}, 2000);} catch (err) {alert('Erreur lors de l\'import: le fichier n\'est pas valide');console.error(err);}}}input.click();});// Multi-selection avec shift+clickrankingContainer.addEventListener('click', e => {const clickedBlock = e.target.closest('.block');if (!clickedBlock) return;if (e.shiftKey) {// Shift+click: toggle selectionclickedBlock.classList.toggle('selected');clickedBlock.classList.toggle('bg-indigo-50');} else {// Regular click: clear other selections and select this onedocument.querySelectorAll('.block.selected').forEach(block => {if (block !== clickedBlock) {block.classList.remove('selected', 'bg-indigo-50');}});clickedBlock.classList.add('selected', 'bg-indigo-50');}});// Bouton de réinitialisationdocument.getElementById('reset-btn').addEventListener('click', () => {if (confirm('Êtes-vous sûr de vouloir réinitialiser toutes les données? Cette action est irréversible.')) {localStorage.removeItem('picRankings');state = {currentWeek: 1,rankings: {1: [...categories]},draggedItem: null};renderBlocks();initWeekSelector();initChart();// Afficher un message de confirmationconst notification = document.createElement('div');notification.className = 'fixed bottom-4 right-4 bg-green-500 text-white px-4 py-2 rounded shadow-lg';notification.textContent = 'Données réinitialisées avec succès!';document.body.appendChild(notification);setTimeout(() => {notification.classList.add('opacity-0', 'transition-opacity', 'duration-300');setTimeout(() => notification.remove(), 300);}, 2000);}});// Drag and droprankingContainer.addEventListener('dragstart', e => {if (e.target.classList.contains('block')) {state.draggedItem = e.target;e.target.classList.add('dragging');e.dataTransfer.effectAllowed = 'move';e.dataTransfer.setData('text/html', e.target.innerHTML);// Afficher le placeholderplaceholder.classList.remove('hidden');}});rankingContainer.addEventListener('dragend', () => {if (state.draggedItem) {state.draggedItem.classList.remove('dragging');placeholder.classList.add('hidden');state.draggedItem = null;}});rankingContainer.addEventListener('dragover', e => {e.preventDefault();e.dataTransfer.dropEffect = 'move';if (!state.draggedItem || e.target === rankingContainer) return;// Déterminer la position du placeholderconst afterElement = getDragAfterElement(rankingContainer, e.clientY);if (afterElement) {rankingContainer.insertBefore(placeholder, afterElement);} else {rankingContainer.appendChild(placeholder);}});rankingContainer.addEventListener('drop', e => {e.preventDefault();if (!state.draggedItem && !state.draggedItems) return;placeholder.classList.add('hidden');// Get the drop positionconst afterElement = getDragAfterElement(rankingContainer, e.clientY);if (state.draggedItems) {// Move multiple blocks while maintaining their orderconst firstBlock = state.draggedItems[0];const referenceNode = afterElement ?(afterElement === firstBlock.nextSibling ? afterElement.nextSibling : afterElement) :null;// Create a temporary container to hold the blocks in orderconst tempContainer = document.createElement('div');state.draggedItems.forEach(item => {item.classList.remove('selected', 'bg-indigo-50', 'dragging');item.style.opacity = '';tempContainer.appendChild(item);});if (afterElement) {rankingContainer.insertBefore(tempContainer, referenceNode);} else {rankingContainer.appendChild(tempContainer);}// Move the blocks out of the temporary containerwhile (tempContainer.firstChild) {if (afterElement) {rankingContainer.insertBefore(tempContainer.firstChild, tempContainer);} else {rankingContainer.appendChild(tempContainer.firstChild);}}tempContainer.remove();} else {// Move single blockstate.draggedItem.classList.remove('dragging');state.draggedItem.style.opacity = '';if (afterElement) {rankingContainer.insertBefore(state.draggedItem, afterElement);} else {rankingContainer.appendChild(state.draggedItem);}}// Update the rankingupdateCurrentRanking();});// Sélecteur de semaineweekSelector.addEventListener('change', e => {const selectedWeek = parseInt(e.target.value);// Vérifier si c'est une nouvelle semaineconst isNewWeek = !state.rankings[selectedWeek];state.currentWeek = selectedWeek;if (isNewWeek) {// Pour une nouvelle semaine, copier le classement de la semaine précédenteconst prevWeek = selectedWeek - 1;if (state.rankings[prevWeek]) {state.rankings[selectedWeek] = [...state.rankings[prevWeek]];} else {state.rankings[selectedWeek] = [...categories];}}renderBlocks();initWeekSelector();initChart();});// Bouton d'enregistrementsaveBtn.addEventListener('click', () => {updateCurrentRanking();saveData();// Créer une nouvelle semaineconst nextWeek = state.currentWeek + 1;state.currentWeek = nextWeek;state.rankings[nextWeek] = [...state.rankings[nextWeek - 1]];// Mettre à jour l'affichagerenderBlocks();initWeekSelector();initChart();// Afficher un message de confirmationconst notification = document.createElement('div');notification.className = 'fixed bottom-4 right-4 bg-green-500 text-white px-4 py-2 rounded shadow-lg';notification.textContent = `Classement enregistré et semaine ${nextWeek} créée!`;document.body.appendChild(notification);setTimeout(() => {notification.classList.add('opacity-0', 'transition-opacity', 'duration-300');setTimeout(() => notification.remove(), 300);}, 2000);});}function getDragAfterElement(container, y) {const draggableElements = [...container.querySelectorAll('.block:not(.opacity-50)')];return draggableElements.reduce((closest, child) => {const box = child.getBoundingClientRect();const offset = y - box.top - box.height / 2;if (offset < 0 && offset > closest.offset) {return { offset: offset, element: child };} else {return closest;}}, { offset: Number.NEGATIVE_INFINITY }).element;}function updateCurrentRanking() {const blocks = rankingContainer.querySelectorAll('.block');state.rankings[state.currentWeek] = Array.from(blocks).map(block => block.dataset.category);// Mettre à jour les numéros de positionblocks.forEach((block, index) => {const positionSpan = block.querySelector('span:first-child');positionSpan.textContent = index + 1;});// Mettre à jour le graphiqueinitCharts();}});</script><p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - 🧬 <a href="https://enzostvs-deepsite.hf.space?remix=masterseb/pic4" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body></html>
README.md+7-5
index.html+712-19