0.0.4 • Published 2 years ago

@senx/discovery-plot v0.0.4

Weekly downloads
-
License
Apache-2.0
Repository
-
Last release
2 years ago

Discovery Plot

Usage

In a Web Environment

With NPM/Yarn

$ npm install @senx/discovery-plot

With CDN

<script nomodule src="https://unpkg.com/@senx/discovery-plot/dist/discovery-plot/discovery-plot.js"></script>
<script type="module" src="https://unpkg.com/@senx/discovery-plot/dist/discovery-plot/discovery-plot.esm.js"></script>

Usage

<html>
<head>
  <title>Test</title>
</head>
<body>
<discovery-plot url="https://warp.senx.io/api/v0/exec">
  1 4 <% DROP NEWGTS 'g' STORE
  1 10 <% 'ts' STORE $g $ts RAND + STU * NOW + NaN NaN NaN RAND ADDVALUE DROP %> FOR
  $g %> FOR
</discovery-plot>
<script nomodule src="https://unpkg.com/@senx/discovery-plot/dist/discovery-plot/discovery-plot.js"></script>
<script type="module" src="https://unpkg.com/@senx/discovery-plot/dist/discovery-plot/discovery-plot.esm.js"></script>
</body>
</html>

Configuration

discovery-tile

This Web component displays a Tile based upon a WarpScript (or FLoWS). The WarpScript is executed when the tile renders.

PropertyAttributeTypeDefaultDescription
debugdebugbooleanfalseEnable debug messages
optionsoptionsParam / stringnew Param()Serialized JSON options (see Params below)
typetypeline, area, scatter, step-area, spline-area, spline, step, step-after, step-before, annotation, bar, display, image, map, gauge, linear-gauge, circle, pie, plot, doughnut, rose, tabular, svgChart type
urlurlstringundefinedexec url of your Warp 10 endpoint or Mobius WebSocket endpoint
langlangwarpscript, flowswarpscriptLanguage used
chartTitlechart-titlestringundefinedTitle of the Tile, not mandatory, could be overridden by the dashboard definition (see Dashboard Definition below).
resultresultDataModel / stringExecution result
<discovery-plot url="https://warp.senx.io/api/v0/exec">
  1 4 <% DROP NEWGTS 'g' STORE
  1 10 <% 'ts' STORE $g $ts RAND + STU * NOW + NaN NaN NaN RAND ADDVALUE DROP %> FOR
  $g %> FOR
</discovery-plot>

Params / Options

Options inherit from higher level. options

NameTypeDefaultDescription
typestringChart type (line, area, scatter, step-area, spline-area, spline, step, step-after, step-before, annotation, bar, display, image, map, gauge, linear-gauge, circle, pie, plot, doughnut, rose, tabular, svg, input:text, input:list, input:secret, input:autocomplete, input:slider, input:date, input:date-range, button)
timeModestring'date'date, timestamp or custom
timeZonestring'UTC'Timezone
timeUnitstring'us'Warp 10 time unit (us, ms, ns)
schemestring'WARP10'Color scheme (COHESIVE, COHESIVE_2, BELIZE, VIRIDIS, MAGMA, INFERNO, PLASMA, YL_OR_RD, YL_GN_BU, BU_GN, WARP10, NINETEEN_EIGHTY_FOUR, ATLANTIS, DO_ANDROIDS_DREAM, DELOREAN, CTHULHU, ECTOPLASM, T_MAX_400_FILM )
showLegendbooleanfalseDisplay the chart legend
fullDateDisplaybooleanfalseDisplay full date on the XAxis
unitstringUnit to be displayed
bgColorstringBackground color of tiles
datasetColorstringOnly for the param field in execution result. Color of the trace
fontColorstringFont color in tiles
borderColorstringBorder color in tiles
showLegendbooleanfalseDisplay chart legend
responsivebooleantrueResponsive charts
showRangeSelectorbooleanfalseDisplay the skyline below line or area charts
autoRefreshnumber-1if positive value, will refresh with a request each autoRefresh second for http requests, milliseconds for WebSocket
showErrorsbooleantrueDisplay errors if any
showStatusbooleantrueDisplay the Warp 10 execution status
expandAnnotationbooleanfalseExpand annotations
schemestring'WARP10'Color scheme ( COHESIVE, COHESIVE_2, BELIZE, VIRIDIS, MAGMA, INFERNO, PLASMA, YL_OR_RD, YL_GN_BU, BU_GN, WARP10, NINETEEN_EIGHTY_FOUR, ATLANTIS, DO_ANDROIDS_DREAM, DELOREAN, CTHULHU, ECTOPLASM, T_MAX_400_FILM, MATRIX, CHARTANA)
eventHandlerstring'type=Regexp,tag=Regexp'Only applies on Tiles and Dashboard. See the events chapter below

Common CSS vars

NameDefault
--gts-classname-font-color#004eff
--gts-labelname-font-color#19A979
--gts-attrname-font-color#ED4A7B
--gts-separator-font-color#a0a0a0
--gts-labelvalue-font-color#000000
--gts-attrvalue-font-color#000000
--warp-view-font-color#000000
--warp-view-bg-colortransparent

Specific charts configuration and CSS styles

EventDescriptionType
drawCustomEvent<void>

line, area, scatter, spline-area, step-area, spline, step, step-after, step-before

NameDefault
--warp-view-chart-label-color#8e8e8e
--warp-view-chart-grid-color#8e8e8e
NameTypeDescription
dataGTS, GTS[], custom dataData to display, numeric GTS only
globalParamsOptionGlobal options (see above) concerning this tile, including chat type
paramsOption[]List of options (see above) concerning each displayed dataset depending of the index of this array
eventsEvents[]List of events to emit (see below)

Supported option per series are:

  • datasetColor: Hex CSS color of the series. ie: '#fff00f'
  • type: Chart type (line, area, scatter, step-area, spline-area, spline, step, step-after, step-before)
  • xAxis: In case of multi-X axis support, represents the index of related axis.
  • yAxis: In case of multi-Y axis support, represents the index of related axis.
1 4 <% 
  DROP NEWGTS 'g' STORE
  1 30 <% 
    'ts' STORE 
    $g $ts RAND + STU * NOW + NaN NaN NaN RAND ADDVALUE DROP 
  %> FOR
$g %> FOR STACKTOLIST 'data' STORE
{ 
  'data' $data 
  'params' [ 
    { 'datasetColor' '#dc3545' 'xAxis' 0 }
    { 'datasetColor' '#ff9900' 'xAxis' 0 }
    { 'type' 'area' 'datasetColor' '#90d743' 'xAxis' 1 }
    { 'datasetColor' 'white' 'xAxis' 0 }
  ]
}  

Custom data for line and scatter only:

<% [ 0 10 <% DROP [ RAND 10 * 5 -   RAND 10 * 5 - ] %> FOR ] %> 'rand' STORE
  {
    'title' 'Test'
    'globalParams' { }
    'data' [
      { 'label' 'A' 'values' @rand }
      { 'label' 'B' 'values' @rand }
    ]
  }

annotation

NameDefault
--warp-view-chart-label-color#8e8e8e
--warp-view-chart-grid-color#8e8e8e
NameTypeDescription
dataGTS, GTS[]Data to display, non-numeric GTS only
globalParamsOptionGlobal options (see above) concerning this tile
paramsOption[]List of options (see above) concerning each displayed dataset depending of the index of this array
eventsEvents[]List of events to emit (see below)

Supported option per series are:

  • datasetColor: Hex CSS color of the series. ie: '#fff00f'

bar

NameDefault
--warp-view-chart-label-color#8e8e8e
--warp-view-chart-grid-color#8e8e8e
NameTypeDescription
dataGTS, GTS[], custom dataData to display
globalParamsOptionGlobal options (see above) concerning this tile
paramsOption[]List of options (see above) concerning each displayed dataset depending of the index of this array
eventsEvents[]List of events to emit (see below)

Supported option per series are:

  • datasetColor: Hex CSS color of the series. ie: '#fff00f'
  • bar
    • horizontal: Bar chart orientation
    • stacked
Custom data:
{
  "title": "Test",
  "columns":  [ "A", "B", "C", "D" ],
  "rows": [
    [ "label X", 15, 56, 44, 22 ],
    [ "label Y", 1, 5, 4, 2 ],
    [ "label Z", 14, 45, 78, 12 ]
  ]
}

display

NameTypeDescription
datanumber, string, custom dataData to display
globalParamsOptionGlobal options (see above) concerning this tile
paramsOption[]List of options (see above) concerning each displayed dataset depending of the index of this array
eventsEvents[]List of events to emit (see below)
  • Option.timeMode:
    • date: convert the value into an ISO date.
    • duration: convert the value to a human-readable duration.
    • custom: display value as is, including HTML.
Custom Data Samples:
{ 'data' 42 'globalParams' { 'timeMode' 'custom' } }
{ 'data' NOW 'globalParams' { 'timeMode' 'date' } }
{ 'data' NOW 5 s - 'globalParams' { 'timeMode' 'duration' } }
{
  'data' '<a href="https://warp10.io/" target="_blank">Warp 10</a>'
  'globalParams' { 'bgColor' '#f57f17' 'fontColor' '#bc5100' 'timeMode' 'custom' }
}
{
  'data' { 'text' 'SenX.io' 'url' 'https://senx.io' }
  'globalParams' { 'bgColor' '#f57f17' 'fontColor' '#bc5100' }
}

map

NameTypeDescription
dataGTS, GTS[], custom dataData to display
globalParamsOptionGlobal options (see above) concerning this tile
paramsOption[]List of options (see above) concerning each displayed dataset depending of the index of this array
eventsEvents[]List of events to emit (see below)
Custom data:
  • string[]: considered as GEOJson
  • GTS[]: considered as Path
Options
NameTypeDescription
tilesstring[]List of custom tile layers
mapTypestringBase tile layer (NONE, DEFAULT, HOT, TOPO, TOPO2, STADIA, STADIA_DARK, TONER, TONER_LITE, TERRAIN, ESRI, SATELLITE, OCEANS, GRAY, GRAYSCALE, WATERCOLOR, CARTODB, CARTODB_DARK)
startLatnumberInitial latitude position
startLongnumberInitial longitude position
startZoomnumberInitial zoom level
maxNativeZoomnumberMaximum zoom number the tile source has available. If it is specified, the tiles on all zoom levels higher than maxNativeZoom will be loaded from maxNativeZoom level and auto-scaled.
maxZoomnumberThe maximum zoom level up to which this layer will be displayed (inclusive).
Params:

Render dots without lines:

{
  'key' 'bases'
  'render' 'dots'
  "color" "#f44336"
  "line" false
}

Render weighted dots:

{
  'key' 'sightings'
  'render' 'weightedDots'
  "color" "#31C0F6cc"
  "borderColor" "#31C0F6"
  "maxValue" 100
  "minValue" 0
}

Gauge, circle

NameDefault
--warp-view-chart-label-color#8e8e8e
--warp-view-chart-grid-color#8e8e8e
NameTypeDescription
dataGTS, GTS[], custom dataData to display
globalParamsOptionGlobal options (see above) concerning this tile
paramsOption[]List of options (see above) concerning each displayed dataset depending of the index of this array
eventsEvents[]List of events to emit (see below)
Params
NameTypeDescription
maxValuenumberMax value for gauge

linear-gauge

NameDefault
--warp-view-chart-label-color#8e8e8e
--warp-view-chart-grid-color#8e8e8e
NameTypeDescription
dataGTS, GTS[], custom dataData to display
globalParamsOptionGlobal options (see above) concerning this tile
paramsOption[]List of options (see above) concerning each displayed dataset depending of the index of this array
eventsEvents[]List of events to emit (see below)
Options
NameTypeDescription
gauge.horizontalbooleanGauge orientation
Params
NameTypeDescription
maxValuenumberMax value for gauge

pie, doughnut, rose

NameDefault
--warp-view-chart-label-color#8e8e8e
--warp-view-chart-grid-color#8e8e8e
NameTypeDescription
dataGTS, GTS[], custom dataData to display
globalParamsOptionGlobal options (see above) concerning this tile
paramsOption[]List of options (see above) concerning each displayed dataset depending of the index of this array
eventsEvents[]List of events to emit (see below)
Custom data:

{ 'key':string 'value':number }[]

Demo

npm run dev