Cookbook

Polymorphic Dashboards

{
  'title' 'My Polymorphic Dashboard'
    'tiles' <% 
      // dummy data
      NOW 'now' STORE
      [ 1 RAND 10 * ROUND <% 'i' STORE 
        NEWGTS 'data-' $i TOSTRING + RENAME 'g' STORE
        1 10 <% 'ts' STORE $g $now $ts STU * - NaN NaN NaN RAND ADDVALUE DROP %> FOR
        $g
      %> FOR ]
      <%
        'i' STORE
        'gts' STORE
        {
          'type' 'display' 'title' $gts NAME
          'w' 1 'h' 1 'x' $i 'y' 0
          'data' $gts VALUES REVERSE 0 GET 100 * ROUND 100.0 /
        }
      %> LMAP
     %>
    'options' {
      'autoRefresh' 3
    }
}
{
  'title' 'My Polymorphic Dashboard'
  'options' {
    'autoRefresh' 5
  }
  'tiles' <% 
    // dummy data
    NOW 'now' STORE
    [ 1 RAND 10 * ROUND <% 'i' STORE 
      NEWGTS 'data-' $i TOSTRING + RENAME 'g' STORE
      1 10 <% 'ts' STORE $g $now $ts STU * - NaN NaN NaN RAND ADDVALUE DROP %> FOR
      $g
    %> FOR ]
    <%
      'i' STORE
      'gts' STORE
      {
        'type' 'area' 'title' $gts NAME
        'w' 12 'h' 1 'x' 0 'y' $i
        'data' $gts 
      }
    %> LMAP
  %>
}

Zoom sync

{
     'title' 'My Dashboard with zoom sync'
     'tiles' [
        {
          'type' 'bar' 'x' 0 'y' 0 'w' 6 'h' 1
          'options' { 'eventHandler' 'type=zoom,tag=chart1' }
          'macro' <%
            NOW 'now' STORE
            [ 1 4 <% 'i' STORE 
              NEWGTS 'data-' $i TOSTRING + RENAME 'g' STORE
              1 10 <% 'ts' STORE $g $now $ts STU * - NaN NaN NaN RAND ADDVALUE DROP %> FOR
              $g
            %> FOR ] 'data' STORE
            {
              'data' $data
              'events' [
                { 'tags' [ 'chart2' ] 'type' 'zoom' }
              ]
            }
          %>
        }
        {
          'type' 'line' 'x' 6 'y' 0 'w' 6 'h' 1
          'options' { 'eventHandler' 'type=zoom,tag=chart2' }
          'macro' <%
            NOW 'now' STORE
            [ 1 4 <% 'i' STORE 
              NEWGTS 'data-' $i TOSTRING + RENAME 'g' STORE
              1 10 <% 'ts' STORE $g $now $ts STU * - NaN NaN NaN RAND ADDVALUE DROP %> FOR
              $g
            %> FOR ] 'data' STORE
            {
              'data' $data
              'events' [
                { 'tags' [ 'chart1' ] 'type' 'zoom' }
              ]
            }
          %>
        }
     ]
  }

Tiles AutoRefresh

{
  'tiles' [
    {
      'type' 'area' 'x' 0 'y' 0 'w' 12 'h' 1
      'options' { 'autoRefresh' 200 }
      'endpoint' 'wss://sandbox.senx.io/api/v0/mobius'
      'macro' <%
        NEWGTS 'data' RENAME 'gts' STORE
        NOW  'now' STORE
        $now 10 s - $now
        <% 200 ms + %>
        <%
          'i' STORE
          $i 1e-6 * SIN 'v' STORE
          $gts $i NaN NaN NaN $v ADDVALUE DROP
        %> FORSTEP
        $gts SORT
      %>
    }
  ]
}

Margins synchronizations

{
  'title' 'My Dashboard with margin sync'
  'vars' { 'data' [] }
  'tiles' [
    {
      'type' 'annotation' 'x' 0 'y' 0 'w' 12 'h' 1
      'options' { 'eventHandler' 'type=(variable|margin),tag=chart' }
      'macro' <%
        {
          'data' $data UNWRAP
          'events' [
            { 'tags' [ 'chart1' ] 'type' 'margin' }
          ]
        }
      %>
    }
    {
      'type' 'line' 'x' 0 'y' 1 'w' 12 'h' 1
      'macro' <%
        20 @senx/rand/RANDOMWALK 'data' STORE
        [ $data mapper.toboolean 0 0 0 ] MAP 'data2' STORE
        {
          'data' $data      
          'events' [
            { 'type' 'variable' 'tags' [ 'chart' ] 'value' { 'data' $data2 WRAP } }
            { 'tags' [ 'chart' ] 'type' 'margin' }
          ]
        }
      %>
    }
  ]
}
{ 'title' 'My Dashboard with margin sync' 'vars' { 'data' [] } 'tiles' [ { 'type' 'annotation' 'x' 0 'y' 0 'w' 12 'h' 1 'options' { 'eventHandler' 'type=(variable|margin),tag=chart' } 'macro' <% { 'data' $data UNWRAP 'events' [ { 'tags' [ 'chart1' ] 'type' 'margin' } ] } %> } { 'type' 'line' 'x' 0 'y' 1 'w' 12 'h' 1 'macro' <% 20 @senx/rand/RANDOMWALK 'data' STORE [ $data mapper.toboolean 0 0 0 ] MAP 'data2' STORE { 'data' $data 'events' [ { 'type' 'variable' 'tags' [ 'chart' ] 'value' { 'data' $data2 WRAP } } { 'tags' [ 'chart' ] 'type' 'margin' } ] } %> } ] }

Explore Discovery tutorials and blog posts on the blog

Found an issue on this page or something missing?

Tell us onSlack iconThe Lounge, the Warp 10 Community Slack.