@@ -60,8 +60,8 @@ import { deepCopy } from "./deepcopy";
6060import { createPlotType } from "@equinor/videx-wellog" ;
6161import { defaultPlotFactory } from "@equinor/videx-wellog" ;
6262import {
63- LithologyInfoTable ,
6463 LithologyTrack ,
64+ LithologyInfoTable ,
6565 LithologyTrackOptions ,
6666} from "../components/LithologyTrack" ;
6767export function indexOfElementByName ( array : Named [ ] , name : string ) : number {
@@ -978,6 +978,28 @@ function createAreaData(
978978 } ;
979979}
980980
981+ async function createLithologyData (
982+ data : [ number | null , number | string | null ] [ ]
983+ ) {
984+ // Remove possibly null values for depth
985+ const data_no_null_depths = data . filter ( ( elem ) => {
986+ return elem [ 0 ] !== null ;
987+ } ) ;
988+ // Setup areas where value used for interval is taken from the first depth (current code has a bug where value is taken from the last depth)
989+ return data_no_null_depths . map ( ( dataRow , index ) => {
990+ const value = dataRow [ 1 ] == null ? Number . NaN : dataRow [ 1 ] . toString ( ) ;
991+ return {
992+ from : dataRow [ 0 ] ,
993+ to :
994+ index < data . length - 1
995+ ? data_no_null_depths [ index + 1 ] [ 0 ]
996+ : dataRow [ 0 ] ,
997+ name : value ,
998+ color : { r : 255 , g : 25 , b : 25 } , // Apparently, this is needed by the mother class in videx, use dummy for now
999+ } ;
1000+ } ) ;
1001+ }
1002+
9811003async function createStackData (
9821004 data : [ number | null , number | string | null ] [ ] ,
9831005 colorTable : ColorTable | undefined ,
@@ -1290,19 +1312,13 @@ function addGraphTrack(
12901312 }
12911313}
12921314function addLithologyTrack (
1293- info : TracksInfo ,
1294- welllog : WellLog ,
1315+ name : string ,
1316+ currentMinMaxPrimaryAxis : [ number , number ] ,
12951317 curves : WellLogCurve [ ] ,
12961318 data : WellLogDataRow [ ] ,
12971319 iPrimaryAxis : number ,
1298- templateTrack : TemplateTrack ,
1299- templateStyles ?: TemplateStyle [ ] ,
1300- colorTables ?: ColorTable [ ] ,
13011320 lithologInfoTable ?: LithologyInfoTable
1302- ) : void {
1303- const templatePlot = templateTrack . plots [ 0 ] ;
1304- const name = templatePlot . name ;
1305-
1321+ ) : LithologyTrack | undefined {
13061322 const iCurve = indexOfElementByName ( curves , name ) ;
13071323 if ( iCurve < 0 ) return ; // curve not found
13081324 const curve = curves [ iCurve ] ;
@@ -1311,58 +1327,20 @@ function addLithologyTrack(
13111327 if ( dimensions !== 1 ) return ;
13121328
13131329 const plotData = preparePlotData ( data , iCurve , iPrimaryAxis ) ;
1314- checkMinMax ( info . minmaxPrimaryAxis , plotData . minmaxPrimaryAxis ) ;
1315-
1316- // make full props
1317- const templatePlotProps = getTemplatePlotProps (
1318- templatePlot ,
1319- templateStyles
1320- ) ;
1321- const templateTrackFullPlot : TemplateTrack = deepCopy ( templateTrack ) ;
1322-
1323- templateTrackFullPlot . title = makeTrackHeader ( welllog , templateTrack ) ;
1324- templateTrackFullPlot . plots [ 0 ] . type = templatePlotProps . type ;
1325-
1326- // curve.valueType === "integer", "string"
1327- const logColor = templatePlotProps . colorTable ;
1328- let colorTable : ColorTable | undefined = undefined ;
1329- if ( logColor ) {
1330- if ( colorTables ) {
1331- colorTable = colorTables . find (
1332- ( colorTable ) => colorTable . name == logColor
1333- ) ;
1334- if ( ! colorTable )
1335- console . error ( "Missed '" + logColor + "' color table" ) ;
1336- } else {
1337- console . error (
1338- "No color tables file given for '" + logColor + "' color table"
1339- ) ;
1340- }
1341- } else {
1342- console . error ( "No color table given in template plot props" ) ;
1343- }
1344- const meta = getDiscreteMeta ( welllog , name ) ;
1345- if ( ! meta && curve . valueType == "integer" )
1346- console . log (
1347- "Discrete meta information for '" +
1348- name +
1349- "' not found. Use default"
1350- ) ;
1351-
1352- const showLines = true ;
1330+ checkMinMax ( currentMinMaxPrimaryAxis , plotData . minmaxPrimaryAxis ) ;
13531331 const options : LithologyTrackOptions = {
13541332 abbr : name , // name of the only plot
13551333 legendConfig : stackLegendConfig ,
1356- data : createStackData . bind ( null , plotData . data , colorTable , meta ) ,
1334+ data : createLithologyData . bind ( null , plotData . data ) ,
13571335 showLabels : true ,
1358- showLines : showLines ,
1336+ showLines : true ,
13591337 lithologyInfoTable : lithologInfoTable ,
13601338 } ;
1361- setStackedTrackOptionFromTemplate ( options , templateTrackFullPlot ) ;
13621339 const track = new LithologyTrack ( undefined as unknown as number , options ) ;
13631340 updateStackedTrackScale ( track ) ;
1364- info . tracks . push ( track ) ;
1341+ return track ;
13651342}
1343+
13661344function addStackedTrack (
13671345 info : TracksInfo ,
13681346 welllog : WellLog ,
@@ -1492,17 +1470,15 @@ export function createTracks(
14921470 break ;
14931471 }
14941472 case "canvas" : {
1495- addLithologyTrack (
1496- info ,
1497- welllog ,
1473+ const lithologyTrack = addLithologyTrack (
1474+ templateTrack . plots [ 0 ] . name ,
1475+ info . minmaxPrimaryAxis ,
14981476 curves ,
14991477 data ,
15001478 iPrimaryAxis ,
1501- templateTrack ,
1502- templateStyles ,
1503- colorTables ,
15041479 lithologyInfoTable
15051480 ) ;
1481+ if ( lithologyTrack ) info . tracks . push ( lithologyTrack ) ;
15061482 break ;
15071483 }
15081484 default : {
0 commit comments