Horizontal Widget

This WellLog Horizontal Widget tutorial demonstrates how to create a horizontal WellLog widget. All the functionality is same as vertical WellLog widget except for the orientation. Similarly, manipulation of the properties of the objects, such as orientation of the text in the index track is also possible.

# Initialization

Create a widget and set its orientation to horizontal, then insert it into the plot. Refer to the WellLog Widgets tutorial for basic information on creating vertical WellLog Widgets.

import { MathUtil } from "@int/geotoolkit/util/MathUtil.ts";
import { LogData } from "@int/geotoolkit/welllog/data/LogData.ts";
import { LogCurve } from "@int/geotoolkit/welllog/LogCurve.ts";
import { LogBarVisual } from "@int/geotoolkit/welllog/LogBarVisual.ts";
import { KnownColors } from "@int/geotoolkit/util/ColorUtil.ts";
import { Orientation } from "@int/geotoolkit/util/Orientation.ts";
import { HeaderType as LogAxisVisualHeaderType } from "@int/geotoolkit/welllog/header/LogAxisVisualHeader.ts";
import { TrackType } from "@int/geotoolkit/welllog/TrackType.ts";
import { from } from "@int/geotoolkit/selection/from.ts";
import { LogAxis } from "@int/geotoolkit/welllog/LogAxis.ts";
import { PaperFormatFactory } from "@int/geotoolkit/scene/exports/PaperFormatFactory.ts";
import { ScalingOptions } from "@int/geotoolkit/scene/exports/ScalingOptions.ts";
import { HeaderComponent } from "@int/geotoolkit/scene/exports/HeaderComponent.ts";
import { FooterComponent } from "@int/geotoolkit/scene/exports/FooterComponent.ts";
import { Plot } from "@int/geotoolkit/plot/Plot.ts";
import { Range } from "@int/geotoolkit/util/Range.ts";
import { PdfExport } from "@int/geotoolkit/pdf/PdfExport.ts";
import { curveData } from "/src/code/WellLog/utils/curveData.ts";
import { createWellLogWidget } from "/src/code/WellLog/utils/common.ts";
let HorizontalWidget = null;
function createTestData(from2, step, curveMnemonic) {
  const depths = [];
  const values = [];
  const curveDat = curveData[curveMnemonic];
  const amountOfPoints = curveDat.length;
  for (let i = 0; i < amountOfPoints; i++) {
    depths.push(i * step + from2);
    values.push(curveDat[i]);
  }
  return new LogData({
    "name": curveMnemonic,
    "depths": depths,
    "values": values
  });
}
function createCurve(dataSource) {
  const limits = MathUtil.calculateNeatLimits(dataSource.getMinValue(), dataSource.getMaxValue(), false, false);
  return new LogCurve(dataSource).setNormalizationLimits(limits.getLow(), limits.getHigh());
}
function createLogBar() {
  const depths = [
    4500,
    4516,
    4532,
    4548,
    4564,
    4580,
    4596,
    4612,
    4628,
    4644,
    4660,
    4676,
    4692,
    4708,
    4724,
    4740,
    4756,
    4772,
    4788,
    4804,
    4820,
    4836,
    4852,
    4868,
    4884,
    4900
  ];
  const values = [15, 25, 9, 35, 30, 25, 40, 25, 30, 35, 40, 100, 80, 90, 100, 90, 95, 90, 40, 90, 40, 35, 40, 35, 40, 35];
  return new LogBarVisual({
    "data": new LogData({
      "name": "BarChart",
      "depths": depths,
      "values": values
    }),
    "linestyle": KnownColors.LightGrey,
    "fillstyle": KnownColors.Orange
  }).setEnableAutoLimits(false).setLimits(new Range(0, 150));
}
function addWidgetToCanvas(canvas, widget) {
  const plot = new Plot({
    "canvaselement": canvas,
    "root": widget
  });
  widget.setHeaderHeight("auto").fitToWidth();
  return plot;
}
function createHorizontalWidget() {
  const widget = createWellLogWidget({
    "orientation": Orientation.Horizontal
  }).setAxisHeaderType(LogAxisVisualHeaderType.Simple);
  widget.addTrack(TrackType.IndexTrack).setLayoutStyle({
    "minwidth": 50,
    "maxwidth": 50
  });
  widget.addTrack(TrackType.LinearTrack).addChild([
    createCurve(createTestData(4500, 10, "GR")).setLineStyle(KnownColors.Green),
    createCurve(createTestData(4500, 10, "CALI")).setLineStyle(KnownColors.Orange),
    createLogBar()
  ]);
  let minDepth = Number.POSITIVE_INFINITY;
  let maxDepth = Number.NEGATIVE_INFINITY;
  from(widget).where((node) => node instanceof LogCurve).select((curve) => {
    const limits = curve.getDataLimits();
    minDepth = Math.min(limits.getTop(), minDepth);
    maxDepth = Math.max(limits.getBottom(), maxDepth);
  });
  widget.setDepthLimits(minDepth, maxDepth);
  from(widget).where((node) => node instanceof LogAxis).selectFirst().setAutoLabelRotation(false).getTickGenerator().setLabelRotationAngle("major", -Math.PI / 2).setVisibleLabelGrade("edge", false);
  return widget;
}
function exportToPDF(widget, errorObj) {
  if (!PdfExport.isSupported()) {
    errorObj.show = true;
    errorObj.text = "Web Browser Does not support pdf export.";
    return;
  }
  widget.exportToPdf({
    "output": "Widget",
    "printsettings": {
      "paperformat": PaperFormatFactory.getInstance().getPaper("Letter"),
      "top": 1,
      "bottom": 1,
      "left": 0.5,
      "right": 0.5,
      "scaling": ScalingOptions.AsIs,
      "keepaspectratio": false,
      "continuous": false,
      "units": "cm"
    },
    "limits": {
      "start": widget.getDepthLimits().getLow(),
      "end": widget.getDepthLimits().getHigh()
    },
    "header": new HeaderComponent(600, 20, "PDF Output"),
    "footer": new FooterComponent(600, 20)
  });
}
function createScene(canvas) {
  HorizontalWidget = createHorizontalWidget();
  return addWidgetToCanvas(canvas, HorizontalWidget);
}
export { createScene, exportToPDF };

createScene(document.querySelector('[ref="plot"]'));

Close

# Manipulate Properties in Widgets

User can easily manipulate properties of the objects in widgets, for example, changing the orientation of labels in the index track can be achieved as follows.