question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

how to populate bind options from data source (not manually)?

See original GitHub issue

I’ve modified the stocks example with a drop-down box to select a company, like this: https://vega.github.io/editor/#/gist/vega/mattijn/a25b9ba41a775cf128d1472cd3e44253 (btw, great update to the new editor!)

But now I’ve to declare the bind > options manually ("GOOG", "MSFT", etc) I was hoping I could make use of a Collect Transform to get all (unique) values from a data source, which I can use in the bind signal. But this seems not be supported?

Issue Analytics

  • State:open
  • Created 6 years ago
  • Reactions:7
  • Comments:15 (4 by maintainers)

github_iconTop GitHub Comments

4reactions
Squaredjcommented, Jun 7, 2018

This would be really nice to have: for example to fill a “bind select” with items straight from the data itself. Any changes in the current Vega-release that would make this possible yet?

1reaction
aodhan-domhnaillcommented, Aug 2, 2019

vega-parser constructs the Spec Scope with bindings that get used in View initialization.

My test case dumps,

(index):119 TypeError: param.options.forEach is not a function
    at select (vega.js:31121)
    at generate (vega.js:31069)
    at bind$1 (vega.js:31034)
    at vega.js:31293
    at Array.forEach (<anonymous>)
    at View.initialize$1 [as initialize] (vega.js:31292)
    at new View (vega.js:34768)

The bind elements are constructed here, which leads us to the forEach call we see in the stack trace

Seems like I could use view.data (see also) to get at the data.

So seems like I just need to stick something like below right here,

if (param.options && !Array.isArray(param.options)) {
  if (param.options.field) {
    param.options = view.data(param.options.name).map(x => x[param.options.field]);
  } else {
    param.options = view.data(param.options.name);
  }
}

I’ll test it out now.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Programmatically Binding DataSource To ComboBox In ...
In this article, we will learn how to bind ComboBox DataSource to Array of objects, List of Objects, DataTable, DataSet, DataView and ...
Read more >
Bind ComboBox or ListBox Control to Data - Windows Forms ...
You can bind the ComboBox and ListBox to data to perform tasks such as browsing data in a database, entering new data, or...
Read more >
Bind a Report to an Object Data Source
You can select the data source in the Report Explorer and switch to the Properties panel to change the data source settings.
Read more >
Simplest way to populate dropdownlist in asp.net (code ...
DropDownList1.DataSource = drpdt; DropDownList1.DataTextField="StringValue"; DropDownList1.DataValueField="CurrencyValue"; DropDownList1.
Read more >
DataSource Overview - Kendo UI for jQuery
Learn more about the Kendo UI for jQuery DataSource component, covering all from binding your web app to local arrays of JavaScript objects...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found