<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by mvp on Medium]]></title>
        <description><![CDATA[Stories by mvp on Medium]]></description>
        <link>https://medium.com/@for.mvpetrov?source=rss-228ab4f2a27f------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*y8e6hVnFbiK_2YmUfTel8g.jpeg</url>
            <title>Stories by mvp on Medium</title>
            <link>https://medium.com/@for.mvpetrov?source=rss-228ab4f2a27f------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 04 Dec 2026 20:29:36 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@for.mvpetrov/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[AI Well Log Interpretation: From a LAS File to a Petrophysical Report in One Prompt]]></title>
            <link>https://medium.com/@for.mvpetrov/ai-well-log-interpretation-from-a-las-file-to-a-petrophysical-report-in-one-prompt-89515245ab68?source=rss-228ab4f2a27f------2</link>
            <guid isPermaLink="false">https://medium.com/p/89515245ab68</guid>
            <category><![CDATA[oil-and-gas]]></category>
            <category><![CDATA[mcp-server]]></category>
            <category><![CDATA[petrophysics]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[geology]]></category>
            <dc:creator><![CDATA[mvp]]></dc:creator>
            <pubDate>Tue, 13 Oct 2026 13:31:01 GMT</pubDate>
            <atom:updated>2026-10-13T13:31:01.800Z</atom:updated>
            <content:encoded><![CDATA[<p><em>Claude, Grok and other AI agents can now work in GeophysX, a free browser-based petrophysics app, over MCP. Three prompts on a public well from Kansas.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TV_YYG-HuwQzsSZVjZwnNQ.png" /></figure><p>A quick-look interpretation is the least interesting part of a petrophysicist’s week. You load the LAS file, get shale volume from gamma ray and porosity from density, look for clean porous rock, build a plot and write two paragraphs about it. The steps are always the same, so I wanted to see whether an AI agent could do it.</p><p>I gave Claude Code a link to a public LAS file from the Kansas Geological Survey and one paragraph of instructions. Five and a half minutes later the well was imported and processed, there was a log plot, and there was a report. All of it happened in a normal petrophysics application, so I could watch each step and change anything I didn’t like.</p><p>Here is the full run:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FibtY8BHxrns%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DibtY8BHxrns&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FibtY8BHxrns%2Fhqdefault.jpg&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/8e40eb8ae9e64d54d03c72d15311996d/href">https://medium.com/media/8e40eb8ae9e64d54d03c72d15311996d/href</a></iframe><p><strong>Why not just ask ChatGPT?</strong></p><p>You can, and you’ll get a Python script. Give a coding agent a LAS file and it will parse it with `lasio`, compute Vsh in pandas, print a table and maybe save a matplotlib plot as a PNG. That plot is a static picture, though. You can’t scroll it, zoom into an interval or change a track scale, and to move a cutoff or change the GR clean line you have to ask the agent to edit the script and run it again.</p><p>I wanted the agent to work with the same tools I use. Then its plot is a live log plot I can scroll and zoom, and if a parameter looks wrong I change it in the form and rerun, without going back to the agent.</p><p>The piece that makes this possible is the Model Context Protocol (MCP), an open standard for letting an AI agent call tools inside another application. GeophysX, the free online well log viewer and petrophysics software I build, now has an MCP server. Claude Code, Claude Desktop, Grok Build, OpenAI Codex, Gemini CLI and Cursor can all connect to it.</p><p>Once connected, the agent can import LAS, LIS and DLIS files from a URL (the KGS database works well for this), read headers, curve lists and per-curve statistics, and run processing from the catalogue: Larionov shale volume, density porosity, Archie saturation, filtering, cropping. If nothing in the catalogue fits, it writes a Python script in the app’s built-in script editor. The script runs right in the browser, and you can open it, read it and change it like any script of your own.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VyOac2xTDrkaCWhUqUrJCg.jpeg" /><figcaption><em>A Python script written by the agent, open in the GeophysX script editor and run in the browser.</em></figcaption></figure><p>The agent also builds log plots with tracks, fills and lithology columns, draws zones on crossplots, and writes Markdown reports with tables and plot images.</p><p><strong>Example 1: a quick look in one prompt</strong></p><p>The well is BLOOM 3–22 in Gove County, Kansas, logged in 2024 through a Lansing-Kansas City carbonate section. This is the prompt from the video, word for word:</p><blockquote>Use geophysx. Load this well from the KGS: <a href="https://kgsimages.blob.core.windows.net/web/web_1/WebDocs/WellLogs/kcc_logs_2026/1057181550.las">https://kgsimages.blob.core.windows.net/web/web_1/WebDocs/WellLogs/kcc_logs_2026/1057181550.las</a></blockquote><blockquote>It’s BLOOM 3–22 in Gove County, Kansas. Do a quick look: shale volume from gamma ray, porosity from density, and point out the cleanest, most porous intervals. Make a plot with the logs and the results and write me a short report with the plot in it.</blockquote><p>It read the header and checked the curve ranges before filling in the Larionov and density porosity forms. Then it built a plot with GR, resistivity, density, Vsh and porosity, and wrote a report with a table of the best intervals.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XavXX5gOv1YrlgEnwEd3UA.jpeg" /><figcaption><em>The agent’s summary on the left, the log plot it built on the right.</em></figcaption></figure><p>The comments under the table were more useful than the table. The best rock it found, about 54 ft of clean limestone at 3766–3836 ft with 14–15% porosity, has a deep resistivity of only about 2 ohm·m. The agent said that this looks like water rather than pay, and that it hadn’t computed water saturation, so treat it as an observation. It also flagged one of its own numbers. At 4282–4293 ft the PE of 2.9 doesn’t fit the limestone matrix it had assumed, so the porosity there could be anywhere from 14.5% to 24% depending on the rock. And it pointed at three thin beds with much higher resistivity (8, 22 and 31 ohm·m) as the more interesting candidates, worth checking against shows and DSTs.</p><p>For a first pass on an unfamiliar well, I’d write roughly the same.</p><p>About the first two words, “Use geophysx”: coding agents also have a shell and web access. Leave that out and the agent may just download the LAS file and analyse it on its own, and you’re back to a terminal full of numbers.</p><p><strong>Example 2: lithology from a neutron-density crossplot</strong></p><p>Same session, next prompt:</p><blockquote>Same well. Make a neutron-density crossplot over the logged interval and split it into limestone, dolomite, sandstone and shale. Write the lithology out as a curve and add a lithology column to the plot. Put the crossplot picture and the percentages of each rock type in the report.</blockquote><p>The agent drew four zones on the crossplot along the standard limestone, sandstone and dolomite lines, with shale above 17 PU on the dense side. It turned them into a lithology curve and added a column to the log plot. Before any of that it cut the interval: the density caliper only opens at 3474.5 ft, and above that the density readings are junk. It’s an easy step to forget on a quick look.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FpYwvbOWhmHg%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DpYwvbOWhmHg&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FpYwvbOWhmHg%2Fhqdefault.jpg&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/9c4218e524a275fa5503b74f4875e81b/href">https://medium.com/media/9c4218e524a275fa5503b74f4875e81b/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eAlJjx_TMyhqRVK68NbsYg.jpeg" /><figcaption><em>Neutron-density crossplot with limestone, dolomite, sandstone and shale zones drawn by the agent.</em></figcaption></figure><p>The result was 44% limestone, 34% shale, 19% dolomite and 3% sandstone. The agent said itself that the dolomite number is probably too high, because neutron and density alone don’t separate shaly carbonate from dolomite well, and suggested a second pass with PE. I agree with it.</p><p>The zones live in an ordinary GeophysX crossplot. If you’d put the dolomite boundary somewhere else, drag it and regenerate the curve.</p><p><strong>Example 3: Archie water saturation and pay</strong></p><p>You can also give the agent your own parameters:</p><blockquote>It’s BLOOM 3–22 in Gove County, Kansas, a Lansing-Kansas City limestone section. Work out water saturation with Archie from the deep resistivity and density porosity. Rw is about 0.05 ohm·m, use the usual a=1, m=2, n=2. Find the intervals where porosity is over 8 %, Sw is under 50 % and shale volume is under 40 %, at least a couple of feet thick. Mark them on a plot with the logs, and give me a table in a short report: top, bottom, thickness, average porosity and Sw.</blockquote><p>The agent ran shale volume, density porosity and Archie with my Rw and exponents, built a pay flag from the cutoffs and shaded it on the plot. It also found the top of the Lansing-Kansas City on its own, from the Heebner Shale gamma-ray spike at 3957.5 ft, and counted the pay inside the LKC separately.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FaDRSFypMdlU%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DaDRSFypMdlU&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FaDRSFypMdlU%2Fhqdefault.jpg&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/bbbf1744e4284ab7b9785e49fe56a294/href">https://medium.com/media/bbbf1744e4284ab7b9785e49fe56a294/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*P5Uxbrmy_Fs5hN50FF-0gQ.jpeg" /><figcaption><em>The agent’s notes on the left; porosity, water saturation and the pay flag on the right.</em></figcaption></figure><p>Two thin beds passed: 4133.5–4136 ft (3 ft, 11% porosity, Sw 37%) and 4542–4544 ft (2.5 ft, 12%, Sw 40%). They are the two resistive beds from the quick look, at about 32 and 23 ohm·m. Only the first is inside the LKC, so the LKC net pay at these cutoffs is 3 ft. The clean limestone at 3766–3836 ft from Example 1 comes out at Sw close to 100% with this Rw, so the agent’s guess that it was water holds up.</p><p>Again, the notes were the useful part. At 4067–4072 ft there is a porous limestone with 13–23% porosity that only just misses: a shaly streak splits it, and the rest sits just above 50% Sw, so a small change in Rw would flip it. In the 4133 ft bed the neutron reads below density porosity, which could be light hydrocarbon or a wrong matrix. And m = 2 is optimistic for oomoldic LKC limestones, where m is often 2.2–2.5, so the agent called its Sw values a screening result, not a final answer.</p><p>The shale cutoff in the prompt matters. Without it, half of the intervals that pass are shales: density porosity reads high in them, and Archie finds pay that isn’t there.</p><p>Tell it what you know: the interval, the units, the lithology, the parameters you trust. The agent reads the header, but it knows nothing about the field beyond that.</p><p><strong>Keeping the petrophysicist in charge</strong></p><p>I didn’t want an agent that quietly overwrites curves, so in GeophysX it can’t apply processing by itself. It fills in the form, writes a note on why it chose those parameters, and the form waits until you press Apply. Overwriting or deleting data and installing a script from the catalogue all ask for confirmation first.</p><p>Everything the agent opens is marked in violet, and each run shows up in the task tray, so you can tell its work from yours at a glance. The plots, crossplots and reports it creates are ordinary documents, and you edit them like your own.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZaVtQeR8gaX8IdoqLgJQAw.jpeg" /><figcaption><em>The Larionov shale volume form, filled in by the agent with its reasoning, waiting for Apply.</em></figcaption></figure><p><strong>What the AI provider sees</strong></p><p>Without an agent, GeophysX runs entirely in your browser and your files stay on your computer. With an agent connected, whatever the agent reads (headers, curve statistics, script output) goes through the GeophysX server to the agent and on to its AI provider. Only connect an agent to data you’re allowed to share with that provider, and revoke the token when you’re done.</p><p><strong>Connecting your agent</strong></p><p>It takes a couple of minutes.</p><p>1. Sign in to <a href="https://www.geophysx.net/">GeophysX</a> (it’s free), open Settings → AI agents (MCP) and create an access token.</p><p>2. Add the server to your agent. For Claude Code:</p><blockquote>claude mcp add — transport http geophysx <a href="https://www.geophysx.net/api/mcp">https://www.geophysx.net/api/mcp</a> \</blockquote><blockquote>— header “Authorization: Bearer gpx_…”</blockquote><p>The settings page has the same command for Claude Desktop, Grok Build, Codex, Gemini CLI and Cursor, with your token already filled in.</p><p>3. Keep GeophysX open in a browser tab. The agent’s tools run there, and if you close the tab, the agent loses them.</p><p>4. Ask the agent to call `whoami` to check the connection, then give it a real task.</p><p>One limitation: chat apps that only connect over OAuth (grok.com, ChatGPT, the claude.ai web connectors) can’t connect yet, because GeophysX uses a personal token for now.</p><p><strong>Try it</strong></p><p>GeophysX and the MCP server are free. You need an account and an AI agent of your own.</p><p>- Step-by-step guide: <a href="https://www.geophysx.net/docs/ai-agents-mcp">AI Well Log Interpretation and Petrophysics via MCP</a></p><p>- The app: <a href="https://www.geophysx.net/">geophysx.net</a></p><p>If you try it on your own wells, tell me where the agent got stuck: a task it couldn’t finish, a processing it had to write from scratch because the catalogue didn’t have it, or a tool you expected it to have. That’s what decides what I add next. Leave it in the comments, with the details if you can.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=89515245ab68" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Create Professional Well Log Plots Online with GeophysX]]></title>
            <link>https://medium.com/@for.mvpetrov/how-to-create-professional-well-log-plots-online-with-geophysx-60e2aa2a4490?source=rss-228ab4f2a27f------2</link>
            <guid isPermaLink="false">https://medium.com/p/60e2aa2a4490</guid>
            <category><![CDATA[geoscience]]></category>
            <category><![CDATA[petrophysics]]></category>
            <category><![CDATA[petroleum-engineering]]></category>
            <category><![CDATA[geophysics]]></category>
            <category><![CDATA[oil-and-gas]]></category>
            <dc:creator><![CDATA[mvp]]></dc:creator>
            <pubDate>Wed, 04 Mar 2026 15:06:00 GMT</pubDate>
            <atom:updated>2026-09-09T10:51:02.450Z</atom:updated>
            <content:encoded><![CDATA[<p>Well log plots — also called <strong>log tracks</strong> or <strong>petrophysical strip charts</strong> — are the standard way to visualise borehole measurements: gamma-ray, resistivity, neutron porosity, density, sonic, and dozens of other curves plotted against depth. GeophysX lets you build multi-track, publication-ready well log plots directly in the browser from LAS, DLIS, or LIS files, with no software to install.</p><p>This guide walks through every step: importing data, building tracks, styling curves, and exporting a high-resolution PNG, BMP image or PDF you can drop straight into a report.</p><blockquote>ℹ️GeophysX works entirely in your browser. Your data never leaves your machine — all processing happens locally using WebAssembly and the browser’s built-in rendering engine.</blockquote><h3>Step 1. Import your well log file</h3><p>Open <strong>GeophysX</strong> and import your well data. Three file formats are supported: .las, .dlis, and .lis. Click the <strong>Import DLIS, LIS, LAS</strong> button in the sidebar and pick the file from the system file picker.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/440/0*9aXv8QZ8FGDHnfiB.png" /></figure><p>GeophysX sidebar with the Import DLIS, LIS, LAS button highlighted</p><p>After import the data tree on the left populates with the file, its frames (for DLIS/LIS) or datasets (for LAS), and the individual well log curves. Each curve is marked with a waveform icon once its data has been fully read into memory.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/296/0*jqW2FDN2PmEYJPJz.png" /></figure><p>Data tree showing imported LAS curves — GR, ILD, ILM, SFL, RHOB, NPLS, DT and more</p><blockquote>💡Don’t have a well log file handy? GeophysX ships with built-in demo datasets. Click <strong>Demo data</strong> in the sidebar import button menu to load a sample LAS file with a full suite of curves and start experimenting right away.</blockquote><h3>Step 2. Open the Well Log Plot viewer</h3><p>GeophysX opens with a <strong>Well Log Plot</strong> document already ready on the first tab — you can start adding tracks immediately. If you need a second plot, click the <strong>+</strong> button on the document tab bar and choose <strong>Plot</strong> from the menu. A new empty plot tab opens alongside the existing ones.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/355/0*vC_lL3cx-W8380w7.png" /></figure><p>Document tab bar — clicking + and selecting Plot to open a new well log plot</p><p>The Well Log Plot consists of a main <strong>chart area</strong> with vertical tracks plotted against depth, and a row of <strong>track headers</strong> at the top. Each header displays the legend for that track — curve names, colors, and scale range.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/985/0*kP14il1GNsU46ABD.png" /></figure><p>Empty Well Log Plot viewer — canvas on the right, configuration panel on the left</p><h3>Step 3. Set the vertical scale</h3><p>The <strong>vertical scale</strong> controls how many metres (or feet) fit per metre of screen height — the standard way petrophysicists describe log resolution. Use the scale <strong>dropdown</strong> in the plot toolbar to pick a preset: common values are 1 : 200, 1 : 500, and 1 : 1000. A finer scale (e.g. 1 : 200) stretches the depth axis and reveals thin beds; a coarser scale (e.g. 1 : 1000) gives a whole-well overview.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/410/0*wtlEvQSC7r5Ue-Ik.png" /></figure><p>Vertical scale dropdown in the plot toolbar — presets 1:200, 1:500, 1:1000</p><blockquote>💡Use a coarse scale (1 : 1000) while composing the track layout to see the full well at once, then switch to 1 : 200 or 1 : 500 before exporting to show formation detail.</blockquote><h3>Step 4. Add tracks by dragging curves from the data tree</h3><p>Tracks are created automatically by dragging curves from the <strong>data tree</strong> onto the plot. There is no “add track” button — the drop target determines what happens:</p><ul><li><strong>Drop onto an existing track title</strong> — the curve is added to that track and both curves share the same track column. Use this to build overlays such as NPLS + RHOB on a single track.</li><li><strong>Drop onto the empty area to the right of all tracks</strong> — a new track is created automatically with that curve inside it.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/999/0*Rk2eTmaRma9HHMNx.png" /></figure><p>Dragging a curve from the data tree onto the plot — drop on a track or on the empty right zone</p><h3>4.1 Reorder visualizations within a track</h3><p>Each curve added to a track appears as a separate row in the track header, stacked top to bottom. Each row shows the curve name, its current min / max values, and units. To change the drawing order — for example, to draw RHOB on top of NPLS — drag one header row onto the other: grab it and drop it on the row you want to swap with. The chart updates immediately.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/486/0*eeHKSwYckZD1-S1X.png" /></figure><p>Dragging a visualization header bar inside a track header to reorder drawing order</p><h3>Step 5. Edit curve appearance</h3><p>Hover over a curve header in the plot header panel to reveal edit and delete buttons. Click the edit button to open style settings. You can configure:</p><ul><li><strong>Title</strong> — set the curve name shown in the track header.</li><li><strong>Minimum / Maximum Value</strong> — define the scale range for the curve axis.</li><li><strong>Color</strong> — pick any color for the curve line.</li><li><strong>Thickness</strong> — adjust line width (1–10 px).</li><li><strong>Line Style</strong> — choose solid, dashed, or dotted stroke.</li><li><strong>Scale</strong> — select linear or logarithmic axis.</li><li><strong>Enable Fill</strong> — shade area between curve and baseline.</li><li><strong>Fill Baseline Value</strong> — set the baseline for fill comparison.</li><li><strong>Color Above Baseline</strong> — fill color when curve is above baseline.</li><li><strong>Color Below Baseline</strong> — fill color when curve is below baseline.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/516/0*ejcKwLRtbzPx2RDw.png" /></figure><p>Curve style settings — title, min/max, color picker, thickness, line style, scale, fill options</p><h3>5.1 Track header labels</h3><p>Hover over a track header in the plot header panel to reveal edit and delete buttons. Click the edit button to open track settings. You can configure:</p><ul><li><strong>Title</strong> — set the track label shown in the header.</li><li><strong>Title color</strong> — set color for the header label.</li><li><strong>Background color</strong> — set background color for the track header.</li><li><strong>Grid line color</strong> — set color for the track grid lines.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/516/0*UE81PCHo3LN1dvGJ.png" /></figure><p>Track headers displaying curve name, units, and min/max scale values</p><h3>Step 6. Build a full petrophysical log plot</h3><p>A professional well log plot typically contains the following standard tracks. Use this layout as a starting point and adapt it to your project:</p><ol><li><strong>Track 1 — GR &amp; Caliper:</strong> GR + CALD.</li><li><strong>Track 2 — SP &amp; Microresistivity:</strong> SP + MINV and MNOR. SP deflections and micro-curve separation indicate permeable beds.</li><li><strong>Track 3 — Resistivity:</strong> ILD (deep), ILM (medium), SFL (shallow) — all in ohm/m, log scale. Use red for ILD, blue for ILM, green for SFL.</li><li><strong>Track 4 — Density-Neutron:</strong> RHOB + NPLS reversed. Crossover shading marks gas-bearing intervals. Add DRHO as a thin dashed line to flag rugose borehole.</li><li><strong>Track 5 — Sonic:</strong> DT (40–140 μs/ft, linear). Optionally overlay PE (0–10 b/E) on a secondary axis for lithology discrimination.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*r2ISskyWOJg1OxM6.png" /></figure><p>Completed 5-track petrophysical well log plot — GR, SP/micro-resistivity, ILD/ILM/SFL, RHOB/NPLS, DT</p><blockquote>💡Drag track columns left or right in the configuration panel to reorder them. Hold the track header right border and drag to resize a track width.</blockquote><h3>Step 7. Export the plot as an image or PDF</h3><p>When you are happy with the layout, click the <strong>Export</strong> button in the toolbar above the canvas. A dropdown menu lets you choose the export format:</p><ul><li><strong>PNG Image</strong> — ideal for reports and presentations.</li><li><strong>PDF Document</strong> — vector output for publication or printing.</li><li><strong>BMP Image (Stream)</strong> — raw bitmap for specialized workflows. Suitable for exporting very large plots when PNG and PDF may not handle the size.</li></ul><p>After selecting a format, a standard file save dialog appears allowing you to choose the location and file name. The plot is exported at the default resolution and full depth range.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*-RJJk70hcTrDpKve.png" /></figure><p>The exported PNG well log plot opened in an image viewer — 300 DPI, full depth range</p><blockquote>💡For very long wells, increase the <strong>Scale</strong> value (pixels per depth unit) in the Depth settings before exporting. This stretches the plot vertically, making individual features easier to see in the final image.</blockquote><h3>Tips for professional-looking plots</h3><h3>Use logarithmic scale for resistivity</h3><p>Resistivity values can range from 0.2 Ω·m in brine-saturated shale to over 1000 Ω·m in tight carbonates. A linear scale compresses the interesting variation into a thin sliver. Switch to Log scale in the curve settings and set Min to 0.2, Max to 2000 for a standard 4-decade display.</p><h3>Reverse the neutron porosity axis</h3><p>By convention, neutron porosity (NPLS, in %) is plotted with its axis reversed — high porosity on the left, low on the right — so that the neutron-density crossover (gas effect) opens to the right. Set Min to 45 and Max to -15 (note the reversal). The demo file stores NPLS in percent, so use percent values, not fractions.</p><h3>Match track widths to curve importance</h3><p>Resistivity and neutron-density tracks are usually wider than GR tracks because they carry more interpretive information. Drag the track dividers on the canvas to allocate width proportionally.</p><h3>Troubleshooting</h3><h3>Export fails for very large plots</h3><p>Exporting extremely tall plots (e.g. full-well at high vertical scale) to PNG or PDF may fail or produce errors due to browser or memory limits. In such cases, use BMP export, which streams the image and handles large sizes reliably.</p><h3>The plot is very slow to render with many tracks</h3><p>Narrow the depth range to the interval of interest. Rendering a 10 000 m well at 5 pixels per metre generates a very tall canvas. You can also reduce the <strong>Scale</strong> value while composing the layout and increase it only for the final PNG export.</p><p><a href="https://youtu.be/Nq8OGVJZURE">https://youtu.be/Nq8OGVJZURE</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=60e2aa2a4490" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Online Tools for Viewing Petrophysical LAS Files: A Practical Review]]></title>
            <link>https://medium.com/@for.mvpetrov/online-tools-for-viewing-petrophysical-las-files-a-practical-review-17eb661a2175?source=rss-228ab4f2a27f------2</link>
            <guid isPermaLink="false">https://medium.com/p/17eb661a2175</guid>
            <category><![CDATA[petrophysics]]></category>
            <category><![CDATA[geoscience]]></category>
            <category><![CDATA[well-logging]]></category>
            <category><![CDATA[oil-and-gas]]></category>
            <category><![CDATA[geophysics]]></category>
            <dc:creator><![CDATA[mvp]]></dc:creator>
            <pubDate>Wed, 18 Feb 2026 20:16:00 GMT</pubDate>
            <atom:updated>2026-09-09T10:59:32.213Z</atom:updated>
            <content:encoded><![CDATA[<p><em>A hands-on comparison of free, browser-based viewers for well log ASCII standard files</em></p><h3>Introduction</h3><p>The LAS (Log ASCII Standard) file format has been the backbone of well log data exchange in the oil and gas industry for decades. Whether you are a petrophysicist, geologist, or reservoir engineer, there comes a time when you need to quickly inspect a LAS file without firing up a full-featured — and expensive — desktop application like Techlog, Interactive Petrophysics (IP), or Petrel.</p><p>Browser-based tools have matured significantly in recent years. In this article, I review four online options that let you upload or open a LAS file directly in your browser — no installation required. They range widely in scope: from dead-simple single-purpose viewers to full-blown browser-based IDEs capable of scripting, computation, and custom visualization. One important constraint: all tools covered here process your data entirely in the browser — your LAS files never leave your machine and are not uploaded to any third-party server. In an industry where well data is often confidential, that matters.</p><p><strong>Tools reviewed:</strong></p><ol><li><a href="http://geomechanics.io/"><strong>GeoMechanics.io</strong></a> — Visualise &amp; Analyse LAS Files</li><li><strong>G6 Tools QuickLook</strong> — Quick petrophysical LAS viewer</li><li><strong>JupyterLite — </strong>Python notebook in the browser with lasio</li><li><strong>GeophysX</strong> — Web-based log viewer</li></ol><h3>Evaluation Criteria</h3><p>Each tool is assessed against the following criteria:</p><ul><li><strong>Ease of use. </strong>How quickly can you load a file and see logs?</li><li><strong>Curve display. </strong>Track layout, curve colours, scales</li><li><strong>Header inspection. </strong>Can you read well metadata and curve mnemonics?<strong>Interactivity. </strong>Zoom, pan, depth selection</li><li><strong>Export / sharing. </strong>Can you save plots or data?</li><li><strong>File format support. </strong>LAS 2.0, LIS, DLIS?</li></ul><h3>1. <a href="http://geomechanics.io/">GeoMechanics.io</a> — Visualise &amp; Analyse LAS Files</h3><p><a href="https://www.geomechanics.io/free-tool/visualise-and-analyse-las-files">https://www.geomechanics.io/free-tool/visualise-and-analyse-las-files</a></p><h3>Overview</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VzPygwn5n7hOyugTP16ONA.png" /></figure><h3>What it does well</h3><ul><li>Adding curves is frictionless — just tick them in a checklist</li><li>Built-in statistics panel shows min, max, and mean for each curve</li><li>Depth cursor displays per-curve values at the current position</li><li>Data table view and one-click CSV export</li></ul><h3>Limitations</h3><ul><li>Track layout is determined by internal logic and cannot be adjusted manually</li><li>Curve styles (color, line width, fill) are not configurable</li><li>No control over the depth axis scale (no zoom or scroll — but a depth interval can be specified)</li><li>Curve mnemonics and units are visible, but well metadata (operator, field, location, etc.) is not accessible</li><li>No plot export; since the entire log fits within the page height, a screenshot is the practical workaround</li></ul><h3>2. G6 Tools QuickLook</h3><p><a href="https://g6tools.com/tools/quicklook/index.html">https://g6tools.com/tools/quicklook/index.html</a></p><h3>Overview</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uko76PhNY4Wmp_trKKmtoA.png" /></figure><h3>What it does well</h3><ul><li>Curves are automatically placed on a pre-configured panel as soon as the file is loaded</li><li>Curve styles are fully editable: color, line style, and line width</li><li>Interactive zoom, pan, and depth interval selection</li><li>Built-in petrophysical calculation: Vsh, Porosity, and Water Saturation creates new curves</li></ul><h3>Limitations</h3><ul><li>Track layout is fixed — the number of tracks cannot be changed, and each track accepts only as many curves as the hardcoded form allows</li><li>Curve mnemonics and units are visible, but well metadata (operator, field, location, etc.) is not displayed</li><li>Calculated curves cannot be exported (no CSV or LAS output)</li><li>PDF export is available but fails on long wells, producing a blank white page; no other export formats are supported</li><li>In-browser table preview is limited to the first few rows only</li></ul><h3>3. Jupyter Lite</h3><p><a href="https://jupyter.org/try-jupyter/lab/">https://jupyter.org/try-jupyter/lab/</a></p><h3>Overview</h3><p>JupyterLite is a full Python environment running entirely in the browser via WebAssembly (Pyodide). It is not a purpose-built LAS viewer, but with a few lines of Python and the lasio library it becomes a powerful, flexible tool.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_D_Un6EKod2nGPfu3gIlFQ.png" /></figure><p><strong>Example snippet:</strong></p><pre>%pip install lasio --quiet<br><br>import lasio<br>import matplotlib.pyplot as plt<br>import numpy as np<br>las = lasio.read(&#39;test-file.las&#39;)<br>depth_curve = las.curves[0]<br>depth = depth_curve.data<br>depth_name = depth_curve.mnemonic.strip()<br>depth_unit = depth_curve.unit.strip() if depth_curve.unit else &quot;m&quot;<br>log_curves = las.curves[1:]<br>n_tracks = len(log_curves)<br>if n_tracks == 0:<br>    print(&quot;Only depth curve found - nothing to plot&quot;)<br>else:<br>    fig, axes = plt.subplots(<br>        nrows=1,<br>        ncols=n_tracks,<br>        figsize=(n_tracks * 3 + 2, 12),<br>        sharey=True,<br>        gridspec_kw={&#39;wspace&#39;: 0.08}<br>    )<br>    if n_tracks == 1:<br>        axes = [axes]<br>    for i, curve in enumerate(log_curves):<br>        ax = axes[i]<br>        values = curve.data<br>        name = curve.mnemonic.strip()<br>        unit = curve.unit.strip() if curve.unit else &#39;?&#39;<br>        mask = np.isfinite(values)<br>        ax.plot(values[mask], depth[mask], lw=1.1, color=&#39;darkblue&#39;)<br>        ax.set_title(name, fontsize=11, pad=10)<br>        ax.set_xlabel(f&quot;{name}\n({unit})&quot;, fontsize=9)<br>        ax.grid(True, which=&#39;both&#39;, linestyle=&#39;--&#39;, linewidth=0.6, alpha=0.7, color=&#39;gray&#39;)<br>        xmin, xmax = np.nanmin(values), np.nanmax(values)<br>        if np.isfinite(xmin) and np.isfinite(xmax):<br>            ax.set_xlim(xmin - 0.05 * (xmax - xmin), xmax + 0.05 * (xmax - xmin))<br>    axes[0].set_ylabel(f&quot;{depth_name} ({depth_unit})&quot;, fontsize=11)<br>    axes[0].invert_yaxis()<br>    axes[0].tick_params(axis=&#39;y&#39;, labelsize=9)<br>    axes[0].grid(True, linestyle=&#39;-&#39;, linewidth=0.8, alpha=0.9, color=&#39;lightgray&#39;)<br>    fig.suptitle(&quot;Well Logs&quot;, fontsize=14, y=0.98)<br>    for ax in axes[1:]:<br>        ax.tick_params(labelleft=False)<br>    plt.tight_layout(rect=[0, 0, 1, 0.96])<br>    plt.show()</pre><h3>What it does well</h3><ul><li>Full programmatic access — compute, filter, cross-plot anything</li><li>lasio, pandas, matplotlib available in-browser</li><li>No data leaves your machine (WebAssembly, client-side)</li><li>Free and open source</li></ul><h3>Limitations</h3><ul><li>Not a plug-and-play viewer — requires coding</li><li>Not all Python libraries can run in the browser — packages with native C extensions are unsupported; for example, dlisio does not work in JupyterLite</li><li>No pre-built track layout UI</li><li>Some interactivity is achievable (e.g. with plotly or ipywidgets), but it will never match the fluid, purpose-built experience of a dedicated log viewer</li></ul><h3>4. GeophysX</h3><p><a href="https://www.geophysx.net/app">https://www.geophysx.net/app</a></p><h3>Overview</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GKuQpdMrjZDHJSDUGmeUZw.png" /></figure><h3>What it does well</h3><ul><li>Curves are added by drag-and-drop onto tracks — intuitive and fast</li><li>Tracks are freely configurable: layout, sizing, and arrangement can all be adjusted</li><li>Rich curve styling options including color, line style, and area fill</li><li>Smooth interactivity — zoom and scroll work as expected</li><li>Reads curve mnemonics and units from the header</li><li>Broad format support: LAS, LIS, DLIS, and array data — image logs (e.g. CMI) can be rendered directly in the browser</li><li>Python scripting is supported and the app ships with built-in examples to get you started</li><li>Exports plot (PNG, PDF, BMP)</li><li>Loads even multi-gigabyte DLIS files</li><li>Has embedded data processing (filters, index shift, formula, …)</li></ul><h3>Limitations</h3><ul><li>Well metadata (operator, field, location, etc.) is not displayed</li><li>Processed data export relies entirely on custom scripts, and while examples are provided, the scripting interface is not the most ergonomic experience</li></ul><h3>Side-by-Side Comparison</h3><p>✅ supported · ⚠️ partial / limited · ❌ not supported</p><pre>+----------------------------+-----------------+--------------+-------------+----------+<br>| Feature                    | GeoMechanics.io | G6 QuickLook | JupyterLite | GeophysX |<br>+----------------------------+-----------------+--------------+-------------+----------+<br>| Free, no account           | ✅              | ✅           | ✅          | ✅       |<br>| LIS / DLIS                 | ❌              | ❌           | ❌          | ✅       |<br>| Image logs                 | ❌              | ❌           | ⚠️          | ✅       |<br>| Configurable track layout  | ❌              | ⚠️           | ❌          | ✅       |<br>| Curve style options        | ❌              | ✅           | ✅          | ✅       |<br>| Zoom &amp; pan                 | ❌              | ✅           | ⚠️          | ✅       |<br>| Depth cursor               | ✅              | ❌           | ❌          | ✅       |<br>| Curve mnemonics &amp; units    | ✅              | ✅           | ✅          | ✅       |<br>| Well metadata              | ❌              | ❌           | ✅          | ❌       |<br>| Statistics (min/max/mean)  | ✅              | ❌           | ✅          | ⚠️       |<br>| Petrophysical calculations | ❌              | ✅           | ✅          | ✅       |<br>| Data export (CSV / LAS)    | ✅              | ❌           | ✅          | ⚠️       |<br>| Plot export                | ❌              | ⚠️           | ✅          | ✅       |<br>+----------------------------+-----------------+--------------+-------------+----------+</pre><h3>Conclusions</h3><p>None of these tools is a perfect drop-in replacement for a desktop petrophysics application — and that is fine. Each occupies a different niche.</p><p><a href="http://geomechanics.io/"><strong>GeoMechanics.io</strong></a> is the fastest way to get numbers out of a LAS file. Upload, tick the curves, check statistics, download CSV. No configuration needed, no surprises.</p><p><strong>G6 Tools QuickLook</strong> is the only tool here with built-in petrophysical calculations. If you need a quick Vsh or porosity estimate without writing a single line of code, this is your tool — just be aware that the track layout is rigid and the PDF export is unreliable on long wells.</p><p><strong>JupyterLite + lasio</strong> is not a viewer in the traditional sense — it is a full Python environment in the browser. It rewards users who are comfortable with code: you get complete access to every curve, every header field, and every computation you can express in Python. The trade-off is that there is no GUI; everything is scripted from scratch.</p><p><strong>GeophysX</strong> is the most capable dedicated viewer of the four. Drag-and-drop curve placement, freely configurable tracks, rich styling, smooth interactivity, and-crucially-support for LIS and DLIS formats make it stand out. The somewhat rough scripting interface is a real gap, but for pure log viewing it is the strongest option here. The tool is marked as under development, which shows in a few rough edges — but also makes it the one to watch.</p><p><strong>Quick picks by use case:</strong></p><ul><li><strong>Need numbers fast from a LAS file</strong> → <a href="http://geomechanics.io/">GeoMechanics.io</a></li><li><strong>Quick petrophysical QC without coding</strong> → G6 Tools QuickLook</li><li><strong>Custom analysis, cross-plots, or scripted QC</strong> → JupyterLite + lasio</li><li><strong>Working with LIS / DLIS, or need a proper configurable viewer</strong> → GeophysX</li></ul><p><em>Did I miss a tool you rely on? Drop a comment below — I’d love to know what the community uses for quick LAS inspection or even in-browser editing.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=17eb661a2175" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Global react tooltip for clipped text with ellipsis]]></title>
            <link>https://medium.com/@for.mvpetrov/global-react-tooltip-for-clipped-text-with-ellipsis-98f7d530f0c0?source=rss-228ab4f2a27f------2</link>
            <guid isPermaLink="false">https://medium.com/p/98f7d530f0c0</guid>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[react]]></category>
            <dc:creator><![CDATA[mvp]]></dc:creator>
            <pubDate>Mon, 06 Nov 2023 13:07:16 GMT</pubDate>
            <atom:updated>2023-11-06T13:07:16.100Z</atom:updated>
            <content:encoded><![CDATA[<p>Global react tooltip for clipped text with ellipsis</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4axYVfBRLuw-vZi77G51Mg.png" /></figure><p>Every frontend developer faces the issue of not having enough space to show all the text in the container.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/506/1*ZxXWRRB-kXKB6kt16i2NAA.png" /></figure><p>There is a common CSS solution:</p><pre>.ellipsis {<br>  white-space: nowrap;<br>  overflow: hidden;<br>  text-overflow: ellipsis;<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/439/1*6LaFCx2WxX8fLv8qh5TXEw.png" /></figure><p>Looks better, isn’t it? But what is the full text? In many cases it’s important for the user to know the full text. Ok, we can implement a custom <strong>&lt;EllipsisText/&gt; </strong>component, pass a text as children and track a hover event to show tooltip.</p><pre>&lt;EllipsisText&gt;<br>  elit duis ut duis Lorem excepteur exercitation esse velit culpa sit<br>&lt;/EllipsisText&gt;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/447/1*p0gqlWob4Ag3WJZOLAMWKg.png" /></figure><p>Now we have a tooltip, but it is shown even when the text is not clipped. The ellipsis appears when <strong>offsetWidth </strong>of the element is less then <strong>scrollWidth</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/497/1*r_V4ZeQ2oNyIl-oz_Q0cTg.png" /></figure><p>Great! We have a component which can render a text with ellipsis and show a tooltip.</p><pre>const TodoItem = ({title}) =&gt; (<br>  &lt;List.Item&gt;<br>    &lt;Typography.Title level={5}&gt;<br>      &lt;EllipsisText&gt;<br>        {title}<br>      &lt;/EllipsisText&gt;<br>    &lt;/Typography.Title&gt;<br>  &lt;/Liet.Item&gt;<br>);</pre><p>Every place of the code should be wrapped with <strong>&lt;EllipsisText/&gt;</strong> component. This component wrapper is extra React node and extra DOM element.</p><p>Simple component which renders a list of entity properties</p><pre>const TodoItem = ({date, description, state, title}) =&gt; (<br>  &lt;Description&gt;<br>    &lt;Property title=&#39;title&#39;&gt;<br>      &lt;TodoStateIcon state={state} /&gt;<br>      {title}<br>    &lt;/Property&gt;<br>    &lt;Property title=&#39;description&#39;&gt;<br>      {description}<br>    &lt;/Property&gt;<br>    &lt;Property title=&#39;Date&#39;&gt;<br>      {date.format(&#39;LL LTS&#39;)}<br>    &lt;/Property&gt;<br>    &lt;Property title=&#39;state&#39;&gt;<br>      {formatState(state)}<br>    &lt;/Property&gt;  <br>  &lt;/Description&gt;<br>);</pre><p>becomes a mess of multiple <strong>&lt;EllipsisText/&gt;</strong> wrappers</p><pre>const TodoItem = ({date, description, state, title}) =&gt; (<br>  &lt;Description&gt;<br>    &lt;Property title=&#39;title&#39;&gt;<br>      &lt;EllipsisText&gt;<br>        &lt;TodoStateIcon state={state} /&gt;<br>        {title}<br>      &lt;/EllipsisText&gt;<br>    &lt;/Property&gt;<br>    &lt;Property title=&#39;description&#39;&gt;<br>      &lt;EllipsisText&gt;<br>        {description}<br>      &lt;/EllipsisText&gt;<br>    &lt;/Property&gt;<br>    &lt;Property title=&#39;Date&#39;&gt;<br>      &lt;EllipsisText&gt;<br>        {date.format(&#39;LL LTS&#39;)}<br>      &lt;/EllipsisText&gt;<br>    &lt;/Property&gt;<br>    &lt;Property title=&#39;state&#39;&gt;<br>      &lt;EllipsisText&gt;<br>        {formatState(state)}<br>      &lt;/EllipsisText&gt;<br>    &lt;/Property&gt;  <br>  &lt;/Description&gt;<br>);</pre><h3>Global tooltip for text with ellipsis</h3><p>The suggestion is to use a component which tracks all mouse-hovers on elements with ellipsis and shows a tooltip if the text is clipped. In the <strong>&lt;TodoItem/&gt;</strong> we can just add CSS styles with ellipsis for property values without any changes in initial component code.</p><h4>EllipsisTooltips component</h4><p>Add a listener to document’s <strong>mouseover</strong> event to track all child-hover events.</p><pre>  React.useEffect(() =&gt; {<br>    const mouseOverHandler = (e) =&gt; setHoveredElement(e.target);<br><br>    document.addEventListener(&#39;mouseover&#39;, mouseOverHandler);<br>    return () =&gt; {<br>      document.removeEventListener(&#39;mouseover&#39;, mouseOverHandler);    <br>    }<br>  }, [setHoveredElement]);</pre><p>Hover event can be raised on child of element with ellipsis, so we need to check target and all its ancestors for being clipped text.</p><pre>function findBaseTooltipElement(element) {<br>  const elementStyle = getComputedStyle(element);<br>  if (isStyleWithEllipsis(elementStyle)) {<br>    return isOverflowX(element) ? element : null;<br>  }<br>  if (isStyleWithClamp(elementStyle)) {<br>    return isOverflowY(element) ? element : null;<br>  }<br>  return element.parentElement ? findBaseTooltipElement(element.parentElement) : null;<br>}</pre><p>The component tracks text with ellipsis and text with limited number of lines by using the CSS <strong>line-clamp </strong>property.</p><pre>const isStyleWithEllipsis = (style) =&gt; style.overflowX === &#39;hidden&#39; &amp;&amp;<br>  style.textOverflow === &#39;ellipsis&#39; &amp;&amp;<br>  style.whiteSpace === &#39;nowrap&#39;;<br><br>const isStyleWithClamp = (style) =&gt; style[&#39;-webkit-line-clamp&#39;] &gt; 0;<br><br>const isOverflowX = (element) =&gt; element.offsetWidth &lt; element.scrollWidth;<br><br>const isOverflowY = (element) =&gt; element.offsetHeight &lt; element.scrollHeight;</pre><p><strong>setHoveredElement</strong> from mouseover listener checks that new element is not a child of already hovered element with a shown tooltip</p><pre>const setHoveredElement = React.useCallback((hoveredElement) =&gt; {<br>  if (tooltipBaseElement.current &amp;&amp; tooltipBaseElement.current !== hoveredElement &amp;&amp; !tooltipBaseElement.current.contains(hoveredElement)) {<br>    defineTooltipBaseElement.cancel();<br>    tooltipBaseElement.current = null;<br>    onShowTooltip?.(null);<br>  }<br>  defineTooltipBaseElement(hoveredElement);<br>}, [onShowTooltip, defineTooltipBaseElement]);</pre><p>and calls <strong>defineTooltipBaseElement</strong> function which tries to find should the hovered element have a tooltip. The function is debounced to avoid tooltip flickering and delay tooltip show.</p><pre>const defineTooltipBaseElement = React.useCallback(debounce((element) =&gt; {<br>  const baseElement = findBaseTooltipElement(element);<br>  tooltipBaseElement.current = baseElement;<br>  onShowTooltip?.(baseElement);<br>}, debounceTimeMilliseconds), []);</pre><p>The full code of <strong>&lt;EllipsisTooltips/&gt;</strong> component</p><pre>import React from &#39;react&#39;;<br>import { debounce } from &#39;lodash&#39;;<br><br>function findBaseTooltipElement(element) {<br>  const elementStyle = getComputedStyle(element);<br>  if (isStyleWithEllipsis(elementStyle)) {<br>    return isOverflowX(element) ? element : null;<br>  }<br>  if (isStyleWithClamp(elementStyle)) {<br>    return isOverflowY(element) ? element : null;<br>  }<br>  return element.parentElement ? findBaseTooltipElement(element.parentElement) : null;<br>}<br><br>const isStyleWithEllipsis = (style) =&gt; style.overflowX === &#39;hidden&#39; &amp;&amp;<br>  style.textOverflow === &#39;ellipsis&#39; &amp;&amp;<br>  style.whiteSpace === &#39;nowrap&#39;;<br><br>const isStyleWithClamp = (style) =&gt; style[&#39;-webkit-line-clamp&#39;] &gt; 0;<br><br>const isOverflowX = (element) =&gt; element.offsetWidth &lt; element.scrollWidth;<br><br>const isOverflowY = (element) =&gt; element.offsetHeight &lt; element.scrollHeight;<br><br>export const EllipsisTooltips = React.memo(({<br>  debounceTimeMilliseconds = 300,<br>  onShowTooltip<br>}) =&gt; {<br>  const tooltipBaseElement = React.useRef(null);<br><br>  const defineTooltipBaseElement = React.useCallback(debounce((element) =&gt; {<br>    const baseElement = findBaseTooltipElement(element);<br>    tooltipBaseElement.current = baseElement;<br>    onShowTooltip?.(baseElement);<br>  }, debounceTimeMilliseconds), []);<br>  <br>  const setHoveredElement = React.useCallback((hoveredElement) =&gt; {<br>    if (tooltipBaseElement.current &amp;&amp; tooltipBaseElement.current !== hoveredElement &amp;&amp; !tooltipBaseElement.current.contains(hoveredElement)) {<br>      defineTooltipBaseElement.cancel();<br>      tooltipBaseElement.current = null;<br>      onShowTooltip?.(null);<br>    }<br>    defineTooltipBaseElement(hoveredElement);<br>  }, [onShowTooltip, defineTooltipBaseElement]);<br><br>  React.useEffect(() =&gt; {<br>    const mouseOverHandler = (e) =&gt; setHoveredElement(e.target);<br><br>    document.addEventListener(&#39;mouseover&#39;, mouseOverHandler);<br>    return () =&gt; {<br>      document.removeEventListener(&#39;mouseover&#39;, mouseOverHandler);    <br>    }<br>  }, [setHoveredElement]);<br><br>  return null;<br>});</pre><p>Developer should just define an onShowTooltip callback in props to show a tooltip. Every DOM node with clipped text with ellipsis will have a tooltip on hover.</p><p>Demo shows complex content in first block with ellipsis, 10 random filled blocks with line-clamp and 10 random filled blocks with ellipsis.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/522/1*20D_j3Rt8DWQxT5Hw7lSwA.gif" /></figure><p>Github repository with example <a href="https://github.com/mvp-v/react-ellipsis">is here</a>.</p><p><a href="https://codesandbox.io/s/ellipsis-tooltip-yclvwg">Codesandbox playground</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=98f7d530f0c0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Event bubbling and handling in React JS and DOM]]></title>
            <link>https://medium.com/@for.mvpetrov/event-bubbling-and-handling-in-react-js-and-dom-1a586df2a093?source=rss-228ab4f2a27f------2</link>
            <guid isPermaLink="false">https://medium.com/p/1a586df2a093</guid>
            <category><![CDATA[react]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[mvp]]></dc:creator>
            <pubDate>Mon, 30 Oct 2023 14:25:37 GMT</pubDate>
            <atom:updated>2023-10-30T14:25:37.787Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2uc7bXlzsfNgbQ8IjKjinQ.jpeg" /></figure><p>Event bubbling is a concept in the Document Object Model (DOM) of JavaScript. When a user clicks on an element, for example, a <strong>&lt;div /&gt;</strong>, it first runs the click listener on that <strong>&lt;div /&gt;</strong>, then on its parent, then all the way up on other ancestors until it reaches the window. The event pops up as a bubble from the clicked element to the top level.</p><p>Let’s add a React.</p><pre>const root = ReactDOM.createRoot(document.getElementById(&#39;root&#39;));<br>root.render(<br>  &lt;React.StrictMode&gt;<br>    &lt;App /&gt;<br>  &lt;/React.StrictMode&gt;<br>);</pre><p>And render 3 nested div’s as React components.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/219/1*EzcoOKxmnJ2YW-CHF9rVdQ.png" /></figure><p>React uses a synthetic event wrapper instead of the native browser event to handle events in the DOM. It subscribes to the root element events only. When clicking <strong>div.level3, </strong>DOM click listeners are called in the following order: <strong>div.level3</strong> → <strong>div.level2</strong> → <strong>div.level1</strong> → <strong>div#root</strong>. React is subscribed to <strong>div#root</strong> and receives click event with <strong>target</strong> set to <strong>div.level3.</strong> It generates synthetic event and calls <strong>onClick</strong> handlers at the same bubbling way <strong>div.level3</strong> → <strong>div.level2</strong> → <strong>div.level1</strong>. We are still in DOM bubbling phase and the next step is to call listeners on <strong>document</strong> and <strong>window</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/376/1*t1UISJATjxGLMNILLFP0OQ.png" /></figure><p>React handlers are called after all <strong>div#root</strong> children handled DOM events. That’s why calling <strong>stopPropagation()</strong> inside React handlers only prevents that component’s parents from calling onClick handlers.</p><pre>function TestComponent() {<br>  const ref = React.useRef();<br>  React.useEffect(() =&gt; {<br>    ref.current.addEventListener(&#39;click&#39;, (e) =&gt; {<br>      console.log(&#39;Called first&#39;);<br>    });<br>  }, []);<br><br>  return &lt;div onClick={(e) =&gt; {<br>    console.log(&#39;Called last&#39;);<br>    e.stopPropagation();<br>  }} /&gt;;<br>}</pre><p>React doesn’t receive event if any of its components called DOM <strong>stopPropagation().</strong></p><pre>function TestComponent() {<br>  const ref = React.useRef();<br>  React.useEffect(() =&gt; {<br>    ref.current.addEventListener(&#39;click&#39;, (e) =&gt; {<br>      console.log(&#39;Called first&#39;);<br>      e.stopPropagation();<br>    });<br>  }, []);<br><br>  return &lt;div onClick={(e) =&gt; {<br>    console.log(&#39;Never called&#39;);<br>  }} /&gt;;<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*I1vM7swN2yHdcT5fz8E08A.jpeg" /></figure><p>Why should one use DOM listeners, if React is a powerful tool for all the tricks with events?</p><p><strong>1. Vanilla JS libraries with React wrappers</strong></p><p>A lot of libraries created with Vanilla JS are available with React wrappers. React developer should know about event bubbling to interact properly with these libraries.</p><p><strong>2. Click-outside task</strong></p><p>One of the common tasks is click outside tracking for some popup menu to close it (just subscribe to document click event and check that your component doesn’t contain event.target, example of implementation in <a href="https://github.com/alibaba/hooks/blob/master/packages/hooks/src/useClickAway/index.ts">ahooks</a> library)</p><p><strong>3. Call preventDefault() for passive handlers</strong></p><p>Some listeners of React are <a href="https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener#passive">passive</a>. That’s why implementing custom component behavior for wheel event could be a problem. You can write your logic to handler, but you can’t prevent default scrolling. <strong>addEventListener</strong> solves this problem.</p><p>What was your reason for using <strong>addEventListener </strong>with React?</p><p>And yeah, the picture would not be complete without mentioning the <strong>DOM</strong> capture phase. But so far I have not had any tasks where I needed to use it with React.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/667/1*_6HTHGl0hu2hDKSCUs7-5Q.png" /></figure><p>The repository with example is available <a href="https://github.com/mvp-v/react-event-bubbling">here</a>. It just logs out all phases of click event.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/397/1*0pB8EBfV2HQLG7cEMfs9qQ.png" /></figure><p><a href="https://codesandbox.io/s/gifted-chebyshev-n3xsps?file=/src/App.js">Link for the CodeSandbox</a> to play with. Just set stopPropagation prop for any Block component.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*q0kFQPjDtG2LffPM3iyynw.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1a586df2a093" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Using CSS variables with AntD Design system]]></title>
            <link>https://medium.com/@for.mvpetrov/using-css-variables-with-antd-design-system-3d0cd43c438b?source=rss-228ab4f2a27f------2</link>
            <guid isPermaLink="false">https://medium.com/p/3d0cd43c438b</guid>
            <category><![CDATA[css]]></category>
            <category><![CDATA[ant-design]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[frontend]]></category>
            <category><![CDATA[design-systems]]></category>
            <dc:creator><![CDATA[mvp]]></dc:creator>
            <pubDate>Mon, 23 Oct 2023 14:31:34 GMT</pubDate>
            <atom:updated>2023-11-07T22:46:28.150Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-Mfcewi1a0llJqljGoXZ9Q.jpeg" /></figure><p>Ant Design offers a CSS-in-JS approach for styling your custom components. But how can developers use its Design System tokens in CSS or preprocessors (SASS, LESS)?</p><p>Let’s take a look at a small example with a set of panels with buttons in a row.</p><pre>export const Test: React.FC = () =&gt; (<br>  &lt;div className=&quot;app&quot;&gt;<br>    {map(range(4), (index) =&gt; (<br>      &lt;div<br>        key={index}<br>        className=&#39;container&#39;<br>      &gt;<br>        &lt;Button type=&#39;primary&#39;&gt;<br>          Button {index}<br>        &lt;/Button&gt;<br>      &lt;/div&gt;<br>    ))}<br>  &lt;/div&gt;<br>);</pre><p>Application component is wrapped with ConfigProvider component to set a custom theme.</p><pre>const App: React.FC = () =&gt; (<br>  &lt;ConfigProvider theme={customTheme}&gt;<br>    &lt;CssTokenBridge /&gt;<br>    &lt;Test /&gt;<br>  &lt;/ConfigProvider&gt;<br>);</pre><p>CssTokenBridge is a component for passing token values to CSS variables:</p><pre>import { theme } from &#39;antd&#39;;<br>import { forEach, includes, isNumber, isString, kebabCase } from &#39;lodash&#39;;<br>import React from &#39;react&#39;;<br><br>function saveToken(value, tokenName) {<br>  const isPrivateField = tokenName.startsWith(&#39;_&#39;);<br>  if (isPrivateField) return;<br>  const variableName = `--antd-${kebabCase(tokenName)}`;<br>  if (isString(value)) document.documentElement.style.setProperty(variableName, value);<br>  if (isNumber(value)) {<br>    const propertyValue = isPureNumberProperty(tokenName) ? value : `${value}px`;<br>    document.documentElement.style.setProperty(variableName, propertyValue);<br>  }<br>}<br><br>const isPureNumberProperty = (tokenName) =&gt;<br>  includes(tokenName, &#39;zIndex&#39;) ||<br>  includes(tokenName, &#39;Weight&#39;) ||<br>  includes(tokenName, &#39;motion&#39;) ||<br>  includes(tokenName, &#39;opacity&#39;) ||<br>  includes(tokenName, &#39;lineHeight&#39;);<br><br>export const CssTokenBridge = () =&gt; {<br>  const { token } = theme.useToken();<br>  React.useLayoutEffect(() =&gt; {<br>    forEach(token, saveToken);<br>  }, [ token ]);<br><br>  return null;<br>};</pre><p>I use kebab case names for CSS variable names and add an <strong>antd</strong> prefix. So, the <strong>colorPrimary</strong> token is saved to the <strong>— antd-color-primary </strong>CSS variable. There is a workaround for defining units of token value. Most of the numeric tokens use <strong>px</strong> units, but some of them should be just numbers (like zIndex, lineHeight). The <strong>isPureNumberProperty</strong> function should return <strong>true</strong> for such tokens.</p><p>Now, we can easily use Design System token values without hard-coded values in styles.</p><pre>.app {<br>  display: flex;<br>  gap: var(--antd-padding-content-horizontal);<br><br>  .container {<br>    background-color: var(--antd-green-1);<br>    border-radius: var(--antd-border-radius);<br>    box-shadow: var(--antd-box-shadow);<br>    padding: var(--antd-padding);<br>  }<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/568/1*2KU52aB3AI-SauqzFT0GpA.png" /></figure><p>One of the advantages of this approach is that it’s easy to supervise design. Token name and its value is available in DevTools.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/392/1*2cd-zmYka_HnroOjy-DbWQ.png" /></figure><p>Hope the next versions of AntD <a href="https://github.com/ant-design/ant-design/issues/45618">will support css variables</a> for dynamically changed custom themes out of the box.</p><p>Repository <a href="https://github.com/mvp-v/antd-css-vars">https://github.com/mvp-v/antd-css-vars</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3d0cd43c438b" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>