Skip to content

Commit

Permalink
feat(yaml format): Allow using variables as chart type
Browse files Browse the repository at this point in the history
  • Loading branch information
kantord committed Mar 13, 2018
1 parent 14ec305 commit cf0cb2a
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/yaml-format/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,14 @@ const rules = [
},
'data': value
})],
[[/(stacked)? *\${([A-z_0-9]+)} (chart|plot|diagram|graph)/], (match, value) => ({
'component': 'chart',
'args': {
'type': '${' + match[2] + '}',
'stacked': match[1] === 'stacked'
},
'data': value
})],
]

const handle_urls = (component) => {
Expand Down
13 changes: 13 additions & 0 deletions src/yaml-format/parser.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -527,6 +527,19 @@ describe('yaml format - attr: syntax', function() {
'data': 'https://example.com/text.json'
}
},
{
'input': {'${var_Name1} chart': [
{'attr:title': 'Hello World'},
{'attr:pi': 3.14},
{'data': 'https://example.com/text.json'}
]},
'output': {
'component': 'chart',
'args': {'loader': 'json', 'type': '${var_Name1}', 'title': 'Hello World',
'pi': 3.14, 'stacked': false},
'data': 'https://example.com/text.json'
}
},
]


Expand Down

0 comments on commit cf0cb2a

Please sign in to comment.