File size: 9,688 Bytes
a9ccb62
 
 
 
 
 
 
 
 
 
 
1ef1f14
 
 
 
 
 
 
 
 
 
 
 
a9ccb62
 
 
1ef1f14
 
a9ccb62
 
 
1ef1f14
a9ccb62
1ef1f14
 
a9ccb62
1ef1f14
 
a9ccb62
 
 
 
1ef1f14
 
 
 
 
 
a9ccb62
 
1ef1f14
a9ccb62
 
 
 
 
 
 
 
 
 
 
 
c30fe65
a9ccb62
 
 
 
 
 
 
c30fe65
a9ccb62
 
 
c30fe65
 
a9ccb62
 
 
c30fe65
 
a9ccb62
 
 
c30fe65
 
a9ccb62
 
 
c30fe65
 
1ef1f14
 
 
c30fe65
 
a9ccb62
 
 
c30fe65
 
a9ccb62
 
 
c30fe65
 
a9ccb62
 
 
c30fe65
 
a9ccb62
 
 
c30fe65
 
a9ccb62
 
 
c30fe65
 
a9ccb62
 
 
1ef1f14
a9ccb62
1ef1f14
 
a9ccb62
 
 
1ef1f14
a9ccb62
1ef1f14
 
a9ccb62
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1ef1f14
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
a9ccb62
 
 
1ef1f14
 
 
 
 
 
0e14448
a9ccb62
1ef1f14
c30fe65
1ef1f14
 
 
0e14448
a9ccb62
1ef1f14
c30fe65
1ef1f14
 
 
0e14448
a9ccb62
0e14448
a9ccb62
 
0e14448
a9ccb62
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
<div class="d3-data-packing"></div>
<style>
    .d3-data-packing {
        font-family: 'Arial', sans-serif;
        margin: 0;
    }

    .d3-data-packing .container {
        max-width: 1000px;
        margin: 0 auto;
        border-radius: 10px;
    }

    .d3-data-packing .sections-container {
        display: flex;
        gap: 20px;
    }

    @media (max-width: 768px) {
        .d3-data-packing .sections-container {
            flex-direction: column;
            gap: 30px;
        }
    }

    .d3-data-packing .section {
        flex: 1;
        margin-bottom: 0;
    }

    .d3-data-packing .section-title {
        font-size: 16px;
        font-weight: bold;
        color: var(--text-color, #333);
        margin: 0 auto 20px auto;
        text-align: center;
        width: 100%;
        display: block;
    }

    .d3-data-packing .dataset {
        display: flex;
        flex-direction: column;
        gap: 3px;
    }

    .d3-data-packing .dataset-row {
        display: flex;
        gap: 3px;
        justify-content: center;
        flex-wrap: wrap;
    }

    .d3-data-packing .grid {
        display: grid;
        gap: 3px;
        margin: 0 auto;
        width: fit-content;
    }

    .d3-data-packing .block {
        width: 30px;
        height: 30px;
        border: 1px solid;
        border-radius: 4px;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 10px;
        font-weight: bold;
        color: white;
        position: relative;
    }

    .d3-data-packing .red {
        background-color: color-mix(in srgb, var(--color-0) 60%, transparent);
        border-color: var(--color-0);
    }

    .d3-data-packing .orange {
        background-color: color-mix(in srgb, var(--color-1) 60%, transparent);
        border-color: var(--color-1);
    }

    .d3-data-packing .yellow {
        background-color: color-mix(in srgb, var(--color-2) 60%, transparent);
        border-color: var(--color-2);
    }

    .d3-data-packing .green {
        background-color: color-mix(in srgb, var(--color-3) 60%, transparent);
        border-color: var(--color-3);
    }

    .d3-data-packing .lightgreen {
        background-color: color-mix(in srgb, var(--color-4) 60%, transparent);
        border-color: var(--color-4);
    }

    .d3-data-packing .lightblue {
        background-color: color-mix(in srgb, var(--color-5) 60%, transparent);
        border-color: var(--color-5);
    }

    .d3-data-packing .blue {
        background-color: color-mix(in srgb, var(--color-6) 60%, transparent);
        border-color: var(--color-6);
    }

    .d3-data-packing .purple {
        background-color: color-mix(in srgb, var(--color-7) 60%, transparent);
        border-color: var(--color-7);
    }

    .d3-data-packing .pink {
        background-color: color-mix(in srgb, var(--color-8) 60%, transparent);
        border-color: var(--color-8);
    }

    .d3-data-packing .gray {
        background-color: var(--surface-bg);
        border-color: color-mix(in srgb, var(--text-color) 30%, transparent);
    }

    .d3-data-packing .packing-false {
        display: grid;
        grid-template-columns: repeat(7, 1fr);
        gap: 3px;
        max-width: calc(7 * 30px + 6 * 3px);
    }

    .d3-data-packing .packing-true {
        display: grid;
        grid-template-columns: repeat(7, 1fr);
        gap: 3px;
        max-width: calc(7 * 30px + 6 * 3px);
    }
</style>
<script>
    (() => {
        const bootstrap = () => {
            const scriptEl = document.currentScript;
            let container = scriptEl ? scriptEl.previousElementSibling : null;
            if (!(container && container.classList && container.classList.contains('d3-data-packing'))) {
                const candidates = Array.from(document.querySelectorAll('.d3-data-packing'))
                    .filter((el) => !(el.dataset && el.dataset.mounted === 'true'));
                container = candidates[candidates.length - 1] || null;
            }
            if (!container) return;
            if (container.dataset) {
                if (container.dataset.mounted === 'true') return;
                container.dataset.mounted = 'true';
            }

            // Apply categorical color palette
            const applyColorPalette = () => {
                try {
                    if (window.ColorPalettes && typeof window.ColorPalettes.getColors === 'function') {
                        const colors = window.ColorPalettes.getColors('categorical', 9);
                        colors.forEach((color, index) => {
                            document.documentElement.style.setProperty(`--color-${index}`, color);
                        });
                    } else {
                        // Fallback to CSS variables or default colors
                        const fallbackColors = [
                            'var(--primary-color, #E889AB)',
                            '#4EA5B7', '#E38A42', '#CEC0FA', '#9B59B6',
                            '#16A085', '#1f77b4', '#ff7f0e', '#2ca02c'
                        ];
                        fallbackColors.forEach((color, index) => {
                            document.documentElement.style.setProperty(`--color-${index}`, color);
                        });
                    }
                } catch (e) {
                    console.warn('ColorPalettes not available, using fallback colors');
                }
            };

            // Apply colors immediately and on theme changes
            applyColorPalette();
            if (window.ColorPalettes && typeof window.ColorPalettes.refresh === 'function') {
                window.ColorPalettes.refresh();
            }

            // Data structure - only colored blocks, no gray blocks
            const dataset = [
                { color: 'red', count: 7, label: 'R' },
                { color: 'orange', count: 3, label: 'O' },
                { color: 'yellow', count: 4, label: 'Y' },
                { color: 'lightgreen', count: 6, label: 'G' },
                { color: 'lightblue', count: 12, label: 'L' },
                { color: 'purple', count: 6, label: 'P' },
                { color: 'pink', count: 4, label: 'K' }
            ];

            const packingFalse = [
                { color: 'red', count: 7, label: 'R' },
                { color: 'orange', count: 3, label: 'O' },
                { color: 'gray', count: 4, label: '-' },
                { color: 'yellow', count: 4, label: 'Y' },
                { color: 'gray', count: 3, label: '-' },
                { color: 'lightgreen', count: 6, label: 'G' },
                { color: 'gray', count: 1, label: '-' },
                { color: 'lightblue', count: 7, label: 'L' },
                { color: 'lightblue', count: 3, label: 'L' },
                { color: 'gray', count: 4, label: '-' },
                { color: 'purple', count: 6, label: 'P' },
                { color: 'gray', count: 1, label: '-' },
                { color: 'pink', count: 4, label: 'K' },
                { color: 'gray', count: 3, label: '-' }
            ];

            const packingTrue = [
                // Ligne 1: 7 R
                { color: 'red', count: 7, label: 'R' },
                // Ligne 2: 3 O + 4 Y (combinaison optimisée)
                { color: 'orange', count: 3, label: 'O' },
                { color: 'yellow', count: 4, label: 'Y' },
                // Ligne 3: 6 G + 1 gris
                { color: 'lightgreen', count: 6, label: 'G' },
                { color: 'gray', count: 1, label: '-' },
                // Ligne 4: 7 L (rangée complète)
                { color: 'lightblue', count: 7, label: 'L' },
                // Ligne 5: 3 L + 4 K (combinaison optimisée)
                { color: 'lightblue', count: 3, label: 'L' },
                { color: 'pink', count: 4, label: 'K' },
                // Ligne 6: 6 P + 1 gris
                { color: 'purple', count: 6, label: 'P' },
                { color: 'gray', count: 1, label: '-' }
            ];

            // Helper function to create blocks
            const createBlocks = (blocks) => {
                return blocks.map(block =>
                    block.count > 0 ? `<div class="block ${block.color}"></div>`.repeat(block.count) : ''
                ).join('');
            };

            // Helper function to create dataset rows
            const createDatasetRows = (dataset) => {
                return dataset.map(item =>
                    `<div class="dataset-row">${createBlocks([item])}</div>`
                ).join('');
            };

            // Create the HTML structure
            container.innerHTML = `
        <div class="container">
          <div class="sections-container">
            <div class="section">
              <label class="section-title">Dataset</label>
              <div class="dataset">
                ${createDatasetRows(dataset)}
              </div>
            </div>

            <div class="section">
              <label class="section-title">Packing = False</label>
              <div class="grid packing-false">
                ${createBlocks(packingFalse)}
              </div>
            </div>

            <div class="section">
              <label class="section-title">Packing = True</label>
              <div class="grid packing-true">
                ${createBlocks(packingTrue)}
              </div>
            </div>
          </div>
        </div>
      `;
        };

        if (document.readyState === 'loading') {
            document.addEventListener('DOMContentLoaded', bootstrap, { once: true });
        } else {
            bootstrap();
        }
    })();
</script>