Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue 241 - Support for update(options) where options will extend current options #340

Merged
merged 4 commits into from
Nov 25, 2019

Conversation

deezone
Copy link
Contributor

@deezone deezone commented Nov 11, 2019

Issue

Description

Adds update() method to support dynamically updating rendering options dynamically after gage has been initially created.

This PR support the following setting:

  • valueFontColor
  • labelFontColor

Test case:

  • test file:
var JustGage = require('justgage');

var gauge = new JustGage({
    id: "gauge", // the id of the html element
    value: 50,
    min: 0,
    max: 100,
    decimals: 2,
    gaugeWidthScale: 0.6,
    label: 'TEST',
    labelFontColor: '000000',
});

const sleep = milliseconds => {
    return new Promise(resolve => setTimeout(resolve, milliseconds));
};

sleep(1000).then(() => {
    gauge.refresh(20);
});

sleep(2000).then(() => {
    gauge.refresh(10);
    console.log('START');
});

sleep(3000).then(() => {
    gauge.refresh(300, 1000, 0);
    console.log('Adjust to 1000 range');
});

sleep(3000).then(() => {
    gauge.refresh(900);
    gauge.update('valueFontColor', 'ff0000');
    console.log('900 RED @ 4000');
});

sleep(4000).then(() => {
    gauge.refresh(500);
    gauge.update('valueFontColor', '000000');
    console.log('500 BLACK');
});

sleep(5000).then(() => {
    gauge.refresh(950);
    gauge.update('valueFontColor', 'ff0000');
    console.log('950 RED');
});

sleep(6000).then(() => {
    gauge.refresh(100);
    gauge.update('valueFontColor', '000000');
    console.log('100 black');
});

sleep(7000).then(() => {
    gauge.refresh(850);
    gauge.update('valueFontColor', 'ff0000');
    console.log('850 RED');
});

sleep(8000).then(() => {
    gauge.refresh(300);
    gauge.update('valueFontColor', '000000');
    console.log('300 Black');
});

sleep(10000).then(() => {
    gauge.refresh(1000);
    gauge.update('valueFontColor', 'ff0000');
    console.log('1000 RED');
});

sleep(12000).then(() => {
    gauge.refresh(1000);
    gauge.update('invalid', 'ff0000');
    console.log('Invalid update setting');
});

sleep(14000).then(() => {
    gauge.refresh(500);
    const options = {
        valueFontColor: '000000',
    };
    gauge.update(options);
    console.log('500 BLACK - options');
});

sleep(16000).then(() => {
    gauge.refresh(900);
    const options = {
        valueFontColor: 'ff0000',
        labelFontColor: 'ff0000',
    };
    gauge.update(options);
    console.log('900 RED - options');
});

the display and console output are:
out

justgage.js Outdated Show resolved Hide resolved
justgage.js Show resolved Hide resolved
justgage.js Outdated Show resolved Hide resolved
Copy link
Collaborator

@robertsLando robertsLando left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Could you please also add the update method to README.md ?

@robertsLando
Copy link
Collaborator

Tx @deezone we can merge this now 👍

@robertsLando robertsLando merged commit ff32c9a into toorshia:master Nov 25, 2019
@robertsLando robertsLando changed the title Issue 241 - Support for refresh(options) where options will extend current options Issue 241 - Support for update(options) where options will extend current options Nov 25, 2019
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants