Отлично, рад что всё работает! Теперь давайте исправим отображение категорий по буримости. Нужно, чтобы каждый интервал категорий пород отображался в своей собственной ячейке, а не汇总在一起. Для этого нужно: 1. Получать категории пород из отдельных интервалов `PO_INT_ROCK_BORE_POIR` 2. Отображать каждый интервал категорий отдельно в колонке "Кат. бур." Вот **исправленная функция `drawWellStructure`** с правильным отображением категорий буримости: ```javascript function drawWellStructure(data, scale = 40) { const graphicsScrollContainer = document.getElementById('graphicsScrollContainer'); if (!graphicsScrollContainer) { console.error('graphicsScrollContainer не найден'); return; } graphicsScrollContainer.innerHTML = ''; graphicsScrollContainer.style.cssText = ''; graphicsScrollContainer.style.overflow = 'auto'; graphicsScrollContainer.style.overflowX = 'auto'; graphicsScrollContainer.style.overflowY = 'scroll'; graphicsScrollContainer.style.height = '100%'; graphicsScrollContainer.style.maxHeight = '100%'; graphicsScrollContainer.style.position = 'relative'; graphicsScrollContainer.style.display = 'block'; graphicsScrollContainer.style.flex = '1'; const activeDocType = data.documentationType || 'primary'; const mergedGeology = createMergedGeologyFromDocumentation(activeDocType); // ПОЛУЧАЕМ ИСХОДНЫЕ ИНТЕРВАЛЫ ДЛЯ КРАСНЫХ МЕТОК let originalIntervals = []; switch (activeDocType) { case 'primary': originalIntervals = xmlData?.primaryDocumentation || []; break; case 'final': originalIntervals = xmlData?.finalDocumentation || []; break; case 'gis': originalIntervals = xmlData?.gisDocumentation || []; break; default: originalIntervals = xmlData?.primaryDocumentation || []; } // ПОЛУЧАЕМ КАТЕГОРИИ ПОРОД ПО БУРИМОСТИ ИЗ XML const rockCategoriesList = []; if (xmlData && xmlData.rawXmlContent) { // Извлекаем категории пород из XML const rockRegex = /[\s\S]*?<\/MR_DBA\.PO_INT_ROCK_BORE_POIR>/g; const rockMatches = xmlData.rawXmlContent.match(rockRegex) || []; for (const rockMatch of rockMatches) { const from = parseFloat(extractValue(rockMatch, 'PO_DOCUM_FROM_POIR') || '0'); const to = parseFloat(extractValue(rockMatch, 'PO_DOCUM_TO_POIR') || '0'); const category = extractValue(rockMatch, 'ID_TYPE_ROCK_BORE_POIR') || 'Не указано'; // Преобразуем категорию в римскую цифру let categoryDisplay = category; const romanMatch = category.match(/([IVX]+)$/i); if (romanMatch) { categoryDisplay = romanMatch[1]; } if (from > 0 && to > 0 && to > from) { rockCategoriesList.push({ from: from, to: to, category: categoryDisplay, originalCategory: category }); } } } console.log('📊 Категорий пород найдено:', rockCategoriesList.length, rockCategoriesList); const assays = xmlData?.assays || []; const realTotalDepth = xmlData?.wellDepth || data.totalDepth; const totalDepth = realTotalDepth; // Отступы const topReserve = 15; const bottomReserve = 50; const contentHeight = totalDepth * scale + topReserve; const totalHeight = contentHeight + bottomReserve; const columnWidth = 70; const drillWidth = 70; const assaysWidth = 150; const headerHeight = 45; function decodeHtmlEntities(text) { if (!text) return ''; const textarea = document.createElement('textarea'); textarea.innerHTML = text; return textarea.value; } // СОЗДАЕМ ОСНОВНОЙ КОНТЕЙНЕР const scrollContent = document.createElement('div'); scrollContent.style.cssText = ` display: block; width: 100%; min-height: ${totalHeight + headerHeight + 20}px; height: auto; position: relative; `; const columnContainer = document.createElement('div'); columnContainer.style.cssText = ` position: relative; width: 100%; background: white; border: 1px solid #cbd5e1; border-radius: 4px; margin-bottom: 20px; `; // ШАПКА const header = document.createElement('div'); header.style.cssText = ` position: sticky; top: 0; z-index: 200; display: flex; height: ${headerHeight}px; background: #e2e8f0; border-bottom: 2px solid #94a3b8; flex-shrink: 0; `; const depthHeader = document.createElement('div'); depthHeader.style.cssText = `width: 60px; min-width: 60px; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 0.7rem; color: #0f172a; border-right: 1px solid #cbd5e1; background: #e2e8f0;`; depthHeader.textContent = 'глубина, м'; const coreHeader = document.createElement('div'); coreHeader.style.cssText = `width: ${columnWidth}px; min-width: ${columnWidth}px; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 0.7rem; color: #0f172a; border-right: 1px solid #cbd5e1; background: #e2e8f0;`; coreHeader.textContent = 'Колонка'; const drillHeader = document.createElement('div'); drillHeader.style.cssText = `width: ${drillWidth}px; min-width: ${drillWidth}px; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 0.7rem; color: #0f172a; border-right: 1px solid #cbd5e1; background: #e2e8f0;`; drillHeader.textContent = 'Кат. бур.'; const assaysHeader = document.createElement('div'); assaysHeader.style.cssText = `width: ${assaysWidth}px; min-width: ${assaysWidth}px; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 0.7rem; color: #0f172a; background: #e2e8f0;`; assaysHeader.textContent = 'Пробы'; header.appendChild(depthHeader); header.appendChild(coreHeader); header.appendChild(drillHeader); header.appendChild(assaysHeader); columnContainer.appendChild(header); // ТЕЛО const bodyContainer = document.createElement('div'); bodyContainer.style.cssText = ` position: relative; min-height: ${contentHeight}px; height: auto; `; const body = document.createElement('div'); body.style.cssText = `display: flex; position: relative; min-height: ${contentHeight}px;`; const depthBody = document.createElement('div'); depthBody.style.cssText = ` position: relative; width: 60px; min-width: 60px; min-height: ${contentHeight}px; padding-top: ${topReserve}px; padding-bottom: ${bottomReserve}px; box-sizing: border-box; background: #f8fafc; border-right: 1px solid #cbd5e1; flex-shrink: 0; `; const coreBody = document.createElement('div'); coreBody.style.cssText = ` position: relative; width: ${columnWidth}px; min-width: ${columnWidth}px; min-height: ${contentHeight}px; padding-top: ${topReserve}px; padding-bottom: ${bottomReserve}px; box-sizing: border-box; background: #ffffff; border-right: 1px solid #cbd5e1; flex-shrink: 0; `; const drillBody = document.createElement('div'); drillBody.style.cssText = ` position: relative; width: ${drillWidth}px; min-width: ${drillWidth}px; min-height: ${contentHeight}px; padding-top: ${topReserve}px; padding-bottom: ${bottomReserve}px; box-sizing: border-box; background: #f8fafc; border-right: 1px solid #cbd5e1; flex-shrink: 0; `; const assaysBody = document.createElement('div'); assaysBody.style.cssText = ` position: relative; width: ${assaysWidth}px; min-width: ${assaysWidth}px; min-height: ${contentHeight}px; padding-top: ${topReserve}px; padding-bottom: ${bottomReserve}px; box-sizing: border-box; background: #ffffff; flex-shrink: 0; `; body.appendChild(depthBody); body.appendChild(coreBody); body.appendChild(drillBody); body.appendChild(assaysBody); bodyContainer.appendChild(body); columnContainer.appendChild(bodyContainer); scrollContent.appendChild(columnContainer); graphicsScrollContainer.appendChild(scrollContent); // === ШКАЛА ГЛУБИНЫ === const finalDepthY = totalDepth * scale + topReserve; // СОБИРАЕМ ГРАНИЦЫ ИЗ ИСХОДНЫХ ИНТЕРВАЛОВ const docBoundaries = new Set(); originalIntervals.forEach(interval => { const from = parseFloat(interval.from); const to = parseFloat(interval.to); if (!isNaN(from) && from > 0 && from < totalDepth) { docBoundaries.add(Math.round(from * 10) / 10); } if (!isNaN(to) && to > 0 && to < totalDepth) { docBoundaries.add(Math.round(to * 10) / 10); } }); // Основные 5-метровые отметки for (let depth = 0; depth <= totalDepth; depth += 5) { const yPos = depth * scale + topReserve; const line = document.createElement('div'); line.style.cssText = `position: absolute; top: ${yPos}px; left: 8px; right: 0; height: 1px; background: #cbd5e1; z-index: 10;`; depthBody.appendChild(line); const label = document.createElement('span'); label.style.cssText = `position: absolute; right: 6px; top: ${yPos}px; font-weight: 600; font-size: 0.65rem; color: #1e293b; background: #f8fafc; padding: 0 2px; transform: translateY(-50%); z-index: 150; white-space: nowrap;`; label.textContent = depth.toString(); depthBody.appendChild(label); } // КРАСНЫЕ МЕТКИ docBoundaries.forEach(depth => { if (depth > 0 && depth < totalDepth) { const yPos = depth * scale + topReserve; const isOnFiveMeter = Math.abs(depth % 5) < 0.01; if (!isOnFiveMeter) { const redLine = document.createElement('div'); redLine.style.cssText = `position: absolute; top: ${yPos}px; left: 8px; right: 0; height: 2px; background: #e74c3c; z-index: 12;`; depthBody.appendChild(redLine); const redLabel = document.createElement('span'); redLabel.style.cssText = `position: absolute; right: 6px; top: ${yPos}px; font-weight: 700; font-size: 0.65rem; color: #e74c3c; background: #f8fafc; padding: 0 2px; transform: translateY(-50%); z-index: 150; white-space: nowrap; border-left: 2px solid #e74c3c;`; redLabel.textContent = depth.toString(); depthBody.appendChild(redLabel); } else { const existingLabels = depthBody.querySelectorAll('span'); existingLabels.forEach(label => { if (parseFloat(label.textContent) === depth && label.style.color !== 'rgb(231, 76, 60)') { label.style.color = '#e74c3c'; label.style.fontWeight = '700'; label.style.borderLeft = '2px solid #e74c3c'; label.style.paddingLeft = '4px'; } }); } } }); // Промежуточные линии for (let depth = 0; depth < totalDepth; depth += 1) { if (depth % 5 !== 0) { let isBoundary = false; for (let boundary of docBoundaries) { if (Math.abs(boundary - depth) < 0.01) { isBoundary = true; break; } } if (!isBoundary) { const yPos = depth * scale + topReserve; const line = document.createElement('div'); line.style.cssText = `position: absolute; top: ${yPos}px; left: 8px; right: 0; height: 1px; background: #e2e8f0; z-index: 10;`; depthBody.appendChild(line); } } } // Забой const bottomLine = document.createElement('div'); bottomLine.style.cssText = `position: absolute; top: ${finalDepthY}px; left: 0; right: 0; height: 2px; background: #e74c3c; z-index: 25;`; depthBody.appendChild(bottomLine); const bottomLabel = document.createElement('span'); bottomLabel.style.cssText = `position: absolute; right: 6px; top: ${finalDepthY}px; font-weight: 700; font-size: 0.7rem; color: #e74c3c; background: #f8fafc; padding: 0 3px; transform: translateY(-50%); z-index: 150; white-space: nowrap; border: 1px solid #e74c3c; border-radius: 2px;`; bottomLabel.textContent = totalDepth % 1 === 0 ? totalDepth.toString() : totalDepth.toFixed(1); depthBody.appendChild(bottomLabel); // Линии забоя в других колонках [coreBody, drillBody, assaysBody].forEach(bodyEl => { const line = document.createElement('div'); line.style.cssText = `position: absolute; top: ${finalDepthY}px; left: 0; right: 0; height: 2px; background: #e74c3c; z-index: 25;`; bodyEl.appendChild(line.cloneNode(true)); }); // === ОТРИСОВКА ГЕОЛОГИИ === const geologyBlocks = []; mergedGeology.forEach((geo, index) => { const topY = geo.from * scale + topReserve; const heightY = (geo.to - geo.from) * scale; if (heightY > 0.5 && topY <= contentHeight) { const block = document.createElement('div'); const bgColor = getStratigraphyBackground({ stratigraphy: geo.stratigraphy, originalStratigraphy: geo.originalStratigraphy }); const isDark = isColorDark(bgColor); block.style.cssText = ` position: absolute; top: ${topY}px; left: 0; width: 100%; height: ${Math.min(heightY, contentHeight - topY)}px; background: ${bgColor}; border: 1px solid rgba(0,0,0,0.3); cursor: pointer; transition: all 0.15s ease; display: flex; align-items: center; justify-content: center; z-index: 20; `; const ageSpan = document.createElement('span'); let rawStratigraphy = geo.originalStratigraphy || geo.stratigraphy || ''; if (rawStratigraphy.includes('&#')) { rawStratigraphy = decodeHtmlEntities(rawStratigraphy); } const finalStratigraphy = convertStratigraphyText(rawStratigraphy); ageSpan.style.cssText = ` font-family: 'GeoindexA', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif !important; font-weight: 700; font-size: 0.75rem; color: ${isDark ? '#ffffff' : '#0f172a'}; background: ${bgColor}; padding: 2px 6px; border-radius: 2px; text-align: center; z-index: 21; letter-spacing: 0.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: ${columnWidth - 8}px; `; ageSpan.textContent = finalStratigraphy || '—'; block.appendChild(ageSpan); if (geo.lcode && window.LITHOLOGY_PATTERNS && window.LITHOLOGY_PATTERNS[geo.lcode]) { const patternOverlay = document.createElement('div'); const patternSize = getPatternSize(scale); const fileName = window.LITHOLOGY_PATTERNS[geo.lcode]; const patternUrl = `litology/${fileName}`; patternOverlay.style.cssText = ` position: absolute; top: 0; left: 0; width: 100%; height: 100%; background-image: url("${patternUrl}"); background-repeat: repeat; background-size: ${patternSize.width}px ${patternSize.height}px; opacity: 0.4; pointer-events: none; z-index: 19; `; block.appendChild(patternOverlay); } block.dataset.layerId = index; block.addEventListener('click', (e) => { e.stopPropagation(); highlightGeologyBlock(index, geologyBlocks); if (window.geologyCards && window.geologyCards[index]) { window.geologyCards[index].scrollIntoView({ behavior: 'smooth', block: 'center' }); window.geologyCards[index].click(); } }); coreBody.appendChild(block); geologyBlocks.push(block); } }); // === ОТРИСОВКА КАТЕГОРИЙ ПОРОД ПО БУРИМОСТИ (КАЖДЫЙ ИНТЕРВАЛ ОТДЕЛЬНО) === rockCategoriesList.forEach((rockCat, idx) => { const topY = rockCat.from * scale + topReserve; const heightY = (rockCat.to - rockCat.from) * scale; if (heightY > 2 && topY <= contentHeight) { const drillCell = document.createElement('div'); drillCell.style.cssText = ` position: absolute; top: ${topY}px; left: 0; width: 100%; height: ${Math.min(heightY, contentHeight - topY)}px; background: ${rockCat.category === 'IV' ? '#fff3cd' : rockCat.category === 'V' ? '#f8d7da' : '#f8fafc'}; display: flex; align-items: center; justify-content: center; flex-direction: column; z-index: 20; border-bottom: 1px solid #e2e8f0; box-sizing: border-box; `; // Отображаем категорию const categorySpan = document.createElement('div'); categorySpan.style.cssText = ` font-size: ${Math.min(14, Math.max(10, heightY / 4))}px; font-weight: 700; color: ${rockCat.category === 'IV' ? '#856404' : rockCat.category === 'V' ? '#721c24' : '#2c3e50'}; text-align: center; background: rgba(255,255,255,0.7); padding: 2px 4px; border-radius: 4px; `; categorySpan.textContent = rockCat.category; drillCell.appendChild(categorySpan); // Если высота позволяет, добавляем подпись if (heightY > 25) { const depthSpan = document.createElement('div'); depthSpan.style.cssText = ` font-size: 8px; color: #6c757d; text-align: center; margin-top: 2px; `; depthSpan.textContent = `${rockCat.from.toFixed(1)}-${rockCat.to.toFixed(1)}м`; drillCell.appendChild(depthSpan); } drillBody.appendChild(drillCell); } }); // === ОТРИСОВКА ИНТЕРВАЛОВ БЕЗ ДОКУМЕНТИРОВАНИЯ === let currentDepth = 0; const actualDocumentationDepth = data.totalDepth; const undocumentedIntervals = []; mergedGeology.forEach((geo) => { if (geo.from > currentDepth + 0.01) { undocumentedIntervals.push({ from: currentDepth, to: geo.from, description: 'Интервал без документирования', isBelowActual: false }); } currentDepth = geo.to; }); if (currentDepth < actualDocumentationDepth - 0.01) { undocumentedIntervals.push({ from: currentDepth, to: actualDocumentationDepth, description: 'Интервал без документирования', isBelowActual: false }); } if (actualDocumentationDepth < totalDepth - 0.01) { undocumentedIntervals.push({ from: actualDocumentationDepth, to: totalDepth, description: 'Ниже глубины документирования', isBelowActual: true }); } undocumentedIntervals.forEach((interval) => { const topY = interval.from * scale + topReserve; const heightY = (interval.to - interval.from) * scale; if (heightY > 0.5) { const isBelowActual = interval.isBelowActual === true; const visualElement = document.createElement('div'); let backgroundStyle, borderStyle, labelText; if (!isBelowActual) { backgroundStyle = `repeating-linear-gradient( 45deg, transparent, transparent 5px, rgba(200, 200, 200, 0.2) 5px, rgba(200, 200, 200, 0.2) 10px )`; borderStyle = '2px dashed #bdc3c7'; labelText = 'Нет данных'; } else { backgroundStyle = `repeating-linear-gradient( -45deg, transparent, transparent 5px, rgba(150, 150, 150, 0.3) 5px, rgba(150, 150, 150, 0.3) 10px )`; borderStyle = '2px dotted #95a5a6'; labelText = 'Ниже глубины док.'; } visualElement.style.cssText = ` position: absolute; top: ${topY}px; left: 0; width: 100%; height: ${heightY}px; background: ${backgroundStyle}; border-left: ${borderStyle}; border-right: ${borderStyle}; z-index: 15; pointer-events: none; `; if (heightY > 30) { const label = document.createElement('div'); label.style.cssText = ` position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); color: ${isBelowActual ? '#7f8c8d' : '#95a5a6'}; font-size: ${Math.min(8, heightY / 4)}px; font-weight: 500; white-space: nowrap; background: rgba(255, 255, 255, 0.85); padding: 2px 6px; border-radius: 3px; pointer-events: none; z-index: 100; font-style: italic; border: 1px ${isBelowActual ? 'dotted' : 'dashed'} #bdc3c7; `; label.textContent = labelText; visualElement.appendChild(label); } coreBody.appendChild(visualElement); // Заполняем пустую область в колонке категорий const drillEmpty = document.createElement('div'); drillEmpty.style.cssText = ` position: absolute; top: ${topY}px; left: 0; width: 100%; height: ${heightY}px; background: #f8fafc; display: flex; align-items: center; justify-content: center; z-index: 15; border-bottom: 1px solid #e2e8f0; `; drillEmpty.innerHTML = ''; drillBody.appendChild(drillEmpty); } }); // === ПУНКТИРНЫЕ ЛИНИИ ПО ГРАНИЦАМ ИНТЕРВАЛОВ === mergedGeology.forEach((geo) => { const topY = geo.from * scale + topReserve; const bottomY = geo.to * scale + topReserve; const topLine = document.createElement('div'); topLine.style.cssText = ` position: absolute; left: 0; right: 0; top: ${topY}px; height: 0px; border-top: 0.5px dashed rgba(0, 0, 0, 0.15); pointer-events: none; z-index: 30; `; assaysBody.appendChild(topLine); if (Math.abs(bottomY - topY) > 2) { const bottomLine = document.createElement('div'); bottomLine.style.cssText = ` position: absolute; left: 0; right: 0; top: ${bottomY}px; height: 0px; border-top: 0.5px dashed rgba(0, 0, 0, 0.15); pointer-events: none; z-index: 30; `; assaysBody.appendChild(bottomLine); } }); // === ОТРИСОВКА ПРОБ === if (window.assaysVisible !== false && assays.length > 0) { drawAssaysInColumn(assaysBody, mergedGeology, scale, assaysWidth, topReserve, totalDepth); } function highlightGeologyBlock(index, blocks) { blocks.forEach((block, i) => { if (i === index) { block.style.border = '2px solid #e74c3c'; block.style.boxShadow = '0 0 0 2px rgba(231, 76, 60, 0.25)'; block.style.zIndex = '25'; } else { block.style.border = '1px solid rgba(0,0,0,0.3)'; block.style.boxShadow = 'none'; block.style.zIndex = '20'; } }); if (window.geologyCards) { document.querySelectorAll('.geology-card').forEach((card, i) => { if (i === index) { card.style.background = '#fff7ed'; card.style.borderLeft = '4px solid #e74c3c'; } else { card.style.background = 'white'; card.style.borderLeft = '4px solid #e9ecef'; } }); } } window.geologyBlocks = geologyBlocks; // ПРИНУДИТЕЛЬНО УСТАНАВЛИВАЕМ ПРОКРУТКУ setTimeout(() => { if (graphicsScrollContainer.scrollHeight > graphicsScrollContainer.clientHeight) { graphicsScrollContainer.style.overflowY = 'scroll'; } else { graphicsScrollContainer.style.overflowY = 'auto'; } console.log('📜 Высота контейнера:', graphicsScrollContainer.clientHeight, 'Высота контента:', graphicsScrollContainer.scrollHeight); }, 100); } ``` **Ключевые изменения для категорий буримости:** 1. **Каждый интервал категории отображается отдельно** - больше не объединяются в один блок 2. **Интервалы категорий определяются по своим собственным границам** из `PO_INT_ROCK_BORE_POIR` 3. **Цветовая индикация** - для категории IV (желтый фон), для V (розовый фон) 4. **Отображение глубины интервала** - если высота позволяет, показываем `from-to` 5. **Размер шрифта адаптируется** под высоту ячейки Если в XML нет данных о категориях пород, колонка "Кат. бур." остается пустой с прочерками.