Sha256: 50406a48887953dbc5e12936bb80914f9431a2e1afdb6b01373b235a3dcdd7b2

Contents?: true

Size: 971 Bytes

Versions: 948

Compression:

Stored size: 971 Bytes

Contents

import React, { useState } from 'react'
import { Button, Gauge } from 'playbook-ui'

const GaugeLiveData = (props) => {
  const [value, setValue] = useState(50)
  const [name, setName] = useState('Name')

  const updateValue = () => {
    setValue(Math.floor(Math.random() * 100))
  }
  const updateName = () => {
    let index = namesArray.indexOf(name)
    if (namesArray.indexOf(name) == 5) {
      index = 0
    } else {
      index += 1
    }
    setName(namesArray[index])
  }
  const namesArray = ['Name', 'Windows', 'Doors', 'Roofing', 'Siding', 'Gutters']

  return (
    <div>
      <Button
          onClick={updateValue}
          text="Update Value"
          {...props}
      />
      <Button
          onClick={updateName}
          text="Update Name"
          {...props}
      />
      <Gauge
          chartData={[{ name: name, value: value }]}
          id="gauge-live-data"
          {...props}
      />
    </div>
  )
}

export default GaugeLiveData

Version data entries

948 entries across 948 versions & 2 rubygems

Version Path
playbook_ui_docs-13.32.0.pre.alpha.PLAY14143264 app/pb_kits/playbook/pb_gauge/docs/_gauge_live_data.jsx
playbook_ui-13.32.0.pre.alpha.PLAY14143264 app/pb_kits/playbook/pb_gauge/docs/_gauge_live_data.jsx
playbook_ui_docs-13.32.0.pre.alpha.PLAY14143260 app/pb_kits/playbook/pb_gauge/docs/_gauge_live_data.jsx
playbook_ui-13.32.0.pre.alpha.PLAY14143260 app/pb_kits/playbook/pb_gauge/docs/_gauge_live_data.jsx
playbook_ui_docs-13.32.0.pre.alpha.PLAY14143255 app/pb_kits/playbook/pb_gauge/docs/_gauge_live_data.jsx
playbook_ui-13.32.0.pre.alpha.PLAY14143255 app/pb_kits/playbook/pb_gauge/docs/_gauge_live_data.jsx
playbook_ui_docs-13.32.0.pre.alpha.PLAY14143251 app/pb_kits/playbook/pb_gauge/docs/_gauge_live_data.jsx
playbook_ui-13.32.0.pre.alpha.PLAY14143251 app/pb_kits/playbook/pb_gauge/docs/_gauge_live_data.jsx