Skip to content

Commit

Permalink
Color option bug fix (beta)
Browse files Browse the repository at this point in the history
  • Loading branch information
Mathieu2301 committed Feb 7, 2022
1 parent 6e8856e commit 81c2e7e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
4 changes: 2 additions & 2 deletions src/chart/study.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ function getInputs(options) {
if (options.pineId) pineInputs.pineId = options.pineId;
if (options.pineVersion) pineInputs.pineVersion = options.pineVersion;

Object.keys(options.inputs).forEach((inputID) => {
Object.keys(options.inputs).forEach((inputID, n) => {
const input = options.inputs[inputID];

pineInputs[inputID] = {
v: input.value,
v: (input.type !== 'color') ? input.value : n,
f: input.isFake,
t: input.type,
};
Expand Down
12 changes: 5 additions & 7 deletions src/classes/PineIndicator.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
* @property {string} inline Input inline name
* @property {string} [internalID] Input internal ID
* @property {string} [tooltip] Input tooltip
* @property {'text' | 'source' | 'integer' | 'float' | 'resolution' | 'bool'} type Input type
* @property {'text' | 'source' | 'integer'
* | 'float' | 'resolution' | 'bool' | 'color'
* } type Input type
* @property {string | number | boolean} value Input default value
* @property {boolean} isHidden If the input is hidden
* @property {boolean} isFake If the input is fake
Expand Down Expand Up @@ -115,12 +117,8 @@ module.exports = class PineIndicator {
text: 'String',
};

if (
(input.type === 'bool' && typeof value !== 'boolean')
|| (input.type === 'integer' && typeof value !== 'number')
|| (input.type === 'float' && typeof value !== 'number')
|| (input.type === 'text' && typeof value !== 'string')
) {
// eslint-disable-next-line valid-typeof
if (types[input.type] && typeof value !== types[input.type].toLowerCase()) {
throw new Error(`Input '${input.name}' (${propI}) must be a ${types[input.type]} !`);
}

Expand Down

0 comments on commit 81c2e7e

Please sign in to comment.