Locale and units
The file always stores meters and millimeters (Units). What the drawing shows is up to you: the renderer converts on display, and resolves every word it draws from its label pack.
Language
For historical reasons the renderer draws Portuguese by default. For English, set the locale and resolve the English labels into the configuration:
import {
INTERACTIVE_RENDER_CONFIG,
WellRenderer,
applyRenderLocale,
} from '@welldot/render';
const renderer = new WellRenderer(svgs, {
locale: 'en',
renderConfig: applyRenderLocale(INTERACTIVE_RENDER_CONFIG, 'en'),
});
Both parts are needed:
localecontrols what the renderer formats directly, such as the inch symbol ("in Portuguese,in.in English).applyRenderLocale(config, locale)returns a copy of the configuration with every label resolved from the built-inRENDER_LABELSpack: construction label prefixes, legend entries, tooltip titles and fields, fracture and cave type words, the continuation prefix, column headers and the overlap label. Everything else in the configuration is unchanged.
To use your own wording, change the resolved strings after applyRenderLocale, for example config.legend.labels.wellScreen = 'Screen'. RENDER_LABELS, resolveRenderLabel and the RenderLabelPack type are exported for building a full pack in another language.
The text inside the data, such as lithology descriptions and unit names, is drawn as written in the file.
Units
new WellRenderer(svgs, {
units: { length: 'ft', diameter: 'inches' },
locale: 'en',
renderConfig: applyRenderLocale(INTERACTIVE_RENDER_CONFIG, 'en'),
});
units is the Units type from @welldot/core: length is 'm' or 'ft' and diameter is 'mm' or 'inches'. It sets the depth scale, the labels and the tooltips. The pump's rated power in its tooltip follows units.power ('kW', 'cv' or 'hp').
Units and locale can also change per draw, without a new renderer:
renderer.draw(well, { units: { length: 'm', diameter: 'mm' } });
A per-draw locale changes only what locale controls (the inch symbol). The labels stay as resolved in the configuration; to switch language fully, create a renderer with the other applyRenderLocale result.
Format helpers
The same formatting is exported for your own tables and legends:
| Function | Example |
|---|---|
formatLength(m, units, locale) | depth in meters to a number string, without the unit symbol; units is 'm' or 'ft', locale is 'en' or 'pt' |
formatDiameter(mm, units, locale) | diameter in millimeters to a number string, without the unit symbol; units is 'mm' or 'inches', locale is 'en' or 'pt' |
getLengthUnit(units) (pair with formatLength) | 'm' or 'ft' |
getDiameterUnit(units, locale?) | 'mm', or '"' / 'in.' |
import { formatDiameter, formatLength } from '@welldot/render';
// units is the single value, not the { length, diameter } object; no unit symbol is added
formatLength(45.72, 'ft', 'en'); // '150'
formatDiameter(168.3, 'inches', 'pt'); // '6,63'
For other conversions, use the unit conversion helpers of @welldot/core.