0.1.7 • Published 4 years ago

rockiot-ui v0.1.7

Weekly downloads
39
License
MIT
Repository
github
Last release
4 years ago

rockiot-ui

v. 0.1.7 release notes (01/06/2020)

  • minor fixes

v. 0.1.6 release notes (01/02/2020)

  • removed double name display for gauges

Features

rockiot-ui is a webcomponent (custom HTML element) created using Vue.js, to add awesome gauges, charts and other components in your HTML pages.

Typical usage of rockiot-ui elements

  • IoT dashboards
  • SaaS metric dashboards
  • Weather Stations

All elements created with rockiot-ui are based on SVG.

rockiot-ui doesn't use any canvas.

For this reason you can customize or even manipulate all elements using standard CSS classes and JS.

Elements

Gauges

  • radial (adapted JS from naikus)
  • linear vertical
  • linear horizontal
  • level

Charts

  • line charts
  • area charts
  • bar charts

Other

  • number box

Demo

A dashboard demo using rockiot-ui

Demo here

demo folder contains all files to run a demo on a web server

How to use

Include the main library in your HTML head.

<html>
  <head>
  //...
  <script src="https://unpkg.com/rockiot-ui@latest/build/rockiot.ui.min.js"></script>
  //...

If you plan to use all the elements

<!-- linear gauge -->
<script src="https://unpkg.com/rockiot-ui@latest/build/rockiot.gauge.linear.js"></script>
<!-- radial, level gauge -->
<script src="https://unpkg.com/rockiot-ui@latest/build/rockiot.gauge.radial.js"></script>
<!-- charts -->
<script src="https://unpkg.com/rockiot-ui@latest/build/rockiot.chart.js"></script>

Otherwise include only the element library

  • https://unpkg.com/rockiot-ui@latest/build/rockiot.gauge.linear.js for all linear gauges
  • https://unpkg.com/rockiot-ui@latest/build/rockiot.gauge.radial.js for all radial gauges
  • https://unpkg.com/rockiot-ui@latest/build/rockiot.chart.js for all charts

Gauges

Attributes for gauges

type="gauge" set a gauge component.

variation="radial" set the gauge variation (radial/linear/level).

radial

<rockiot-ui
  type="gauge"
  variation="radial"
  serial="001"
  variation="radial"
  min="0"
  max="100"
  value="22">
</rockiot-ui>

Charts

<rockiot-ui
  type="chart"
  variation="line"
  serial="001"
  min="0"
  max="100"
  value="22">
</rockiot-ui>

Others

Number Box A number box is simply a box with an animated number value.

<rockiot-ui
  type="number-box"
  serial="nb-1"
  min="0"
  max="100"
  value="22">
</rockiot-ui>

Settings Panel (new)

From this realease if attributes settings is set to 1, clicking on the settings icon you will access to the element setting panel.

You can change any attribute (not the id or the serial) and then apply to the element without page refresh needed.

The setting panel has also a Code button that will show the HTML element that reflects the current attributes. In this way you can easily configure your element, copy the HTML code and paste in your page.

Charts (new)

From this release the chart element doesn't have any external dependency and works offline as well. The charts library has been completely recoded and extended and is based on chartist.js

Attributes

As for standard HTML tags, rockiot-ui has different attributes in order to control and customize it.

Common attributes

attributerequireddefaultdescriptionremarks
serialyesgaugeUnique idYou can also add a different id attribute
typenogaugeComponent typegauge / chart / number-box
namenoGaugeComponent titleempty values supported
unitsnoComponent value unitsempty values supported
minno0Minimum value
maxno100Maximum value
valueyes0Initial value
precisionno2Value precision0 - 5
animationno500Animation duration (ms)0=no animation keep below value update rating
text-colorno#777title and units color
value-colorno#cececedisplay value color
value-bg-colornotransparentdisplay value background color
value-border-colorno0px solid #eaeaeadisplay value border color
control-colorno#000Control icons color
control-bgno#fffControl icons bg color
test-iconnoAdd Autotest icon to the control icons barwrench icon
auto-testno0Run autotest automatically
settingsno1Enable element settings panel (clicking on the settings icon)

Gauges attributes

attributerequireddefaultdescriptionremarks
variationnoradialGauge typeradial / linear / level
orientationnoverticalGauge orientationhorizontal / vertical applied only for linear gauges
startangleno135Gauge start angleapplied only for radial gauges
endtangleno45Gauge end angleapplied only for radial gauges
radiusno40Gauge bar radiusapplied only for radial gauges
sizenomdGauge sizesm=small md=default lg=large
scaleno0Gauge major scaleenable gauge scale : 0=disable 1=enable
ticksno10Gauge scale ticksgauge scale divisions
smallscaleno0Gauge minor scaledisplay a minor scale 0=disable 1=enable applied if scale enabled when enabled add 10 ticsk between each major scale division
needleno0Gauge needle0=disable 1=enable
bar-colorno#444Gauge bar color
progress-colorno#ff0000Gauge progress bar color
scale-colorno#aaaGauge scale color
scale-text-colorno#aaaGauge scale text color
needle-colorno#777Gauge needle fill color
needle-stroke-colorno#000Gauge needle stroke color
auto-colorno0Level gauge auto color< 10%(red) < 25%(orange) < 75%(user) > 75%(green)
zonesno''Zones LimitsString of colors separated by commalinear gauges only

Charts attributes

attributerequireddefaultdescriptionremarks
variationnolineChart typeline / area / bar
chart-backgroundno#ff0000Background color
chart-areano.3Area opacity area/bar charts
chart-lineno1Line stroke width
chart-pointno0Line intersection point width
chart-x-labelsno00 = no labels n = display label every n times
chart-x-datanocountcount = increment now = min:secs time = hrs:min:secsdate = date
progress-colorno#ff0000Chart line/area color
scale-colorno#aaaAxis color
scale-text-colorno#aaaAxis text color

NumberBox attributes

attributerequireddefaultdescriptionremarks
value-colorno#cececedisplay value color
value-bg-colornotransparentdisplay value background color
value-border-colorno0px solid #eaeaeadisplay value border color

Helper CSS Classes

You can even customize rockiot-ui changing the default CSS classes

CSS classdescriptionremarks
rockiot-uiComponent main containerComponent HTML Tag <rockiot-ui/>
.rockiot-wrapperComponent wrapperComponent container wrapper
.rockiot-wrapper-titleComponent title/name
.rockiot-ui-controlComponent control icons bar
.rockiot-ui-control-gauge-linear-verticalComponent control icons bar for linear vertical gauge

Events

By default rockiot-ui emits 2 default events.

  • setting
  • connect

Each event returns the element attribute serial

How to attach your function to emitted events by rockiot-ui

document.getElementById(your_element_id)
  .addEventListener('setting',(serial)=>{
    console.log(serial)
    ....
})

To attach a common function to all rockiot-ui components:

document.querSelectorAll('rockiot-ui')
  .addEventListener('setting',(serial){
      console.log ( serial )
      .... //your function
})

Release notes

v. 0.1.5 fixed readme

v. 0.1.4 release notes (01/01/2020)

  • fixed linear vertical display value with negative min setting

v. 0.1.3 release notes (12/15/2019)

  • charts using built-in library (removed google charts dependency )
  • new attributes for charts:
    • chart-area : opacity settings for area charts
    • chart-line : line charts line width
    • chart-point: point width (line intersection)
    • chart-x-labels : set xAxis labels interval ( ex. 3 = display xAxis label every 3 measures)
    • chart-x-data: xAxis label type ( count = counter , now = current mins:secs , time = hrs:mins:secs , date = current date )
  • new settings attribute (all): see settings panel below

Roadmap

  • Styling with Tailwindcss

Versions

0.1.3

  • charts using built-in library (removed google charts dependency )
  • new attributes for charts:
    • chart-area : opacity settings for area charts
    • chart-line : line charts line width
    • chart-point: point width (line intersection)
    • chart-x-labels : set xAxis labels interval ( ex. 3 = display xAxis label every 3 measures)
    • chart-x-data: xAxis label type ( count = counter , now = current mins:secs , time = hrs:mins:secs , date = current date )
  • new settings attribute (all): see settings panel below

0.1.2

Initial release

VUE Project setup

The source code has been created using Vue.js so you can create your vue project and change it as per you needs.

npm install

Compiles and hot-reloads for development

npm run serve

Compiles and minifies for production

Using vue-cli (destination folder dist)

npm run build

Using laravel-mix (destination folder build)

npm run prod

Run your tests

npm run test

Lints and fixes files

npm run lint

Customize configuration

See Configuration Reference.

Credits

For radial gauge used and adapted JS library from naikus

License

This project is licensed under MIT

0.1.7

4 years ago

0.1.6

4 years ago

0.1.5

4 years ago

0.1.4

4 years ago

0.1.3

4 years ago

0.1.2

4 years ago

0.1.1

4 years ago

0.1.0

4 years ago