score:7
Accepted answer
I solved my question by remapping my hash to a new array. Seems like it might be possible to do this with an original query, but I am not strong on Activerecord/SQL to make it happen.
Here is how I remapped the hash to an array of objects that could be used with D3-generator in Ruby
@referral_source = Client.count(:all, :group => :referral_source)
remap = @referral_source.map {|k, v| { Name: k, Count: v} }
=> {{:Name=>"Internet search (e.g., Google)?", :Count=>26}, ... ]
Then I did a .to_json on that in the view. It took me a lot longer than I thought it would to figure out.
Source: stackoverflow.com
Related Query
- Preparing Data to Plot in d3.js from Ruby on Rails Database
- How to create d3 graph using data from Rails database
- How to pull data from mysql database and visualize with D3.JS?
- Dynamically loading external data from database into d3.js
- Create data visualizations using Express and get data from a PostgreSQL database
- third party API data for ruby on rails web application
- Contour plot from scattered data in JavaScript
- how to visualize data from mysql database in force layout of d3 tool
- Create JSON from database query rails
- how to convert data selected from a postgres database to json or csv to use it with d3js lib?
- "Uncaught ReferenceError" from d3 with importmaps on Ruby On Rails
- Django D3 reading csv data from mongodb to plot graph
- Automatic data display from database using d3
- Why is the histogram not displaying if I read the data from a mysql database
- D3: cannot load json data from database using PHP
- View data in graph from rails
- How can I feed ruby on rails data into d3.js?
- Plotting a line using d3 and an JSON data object passed from rails
- D3js text not reading from database data
- Get data from mysql with json and plot with D3
- How to plot data to map from csv file in D3.js
- Ploting box plot from statistical summary data
- Pulling data from a database for a C3js chart
- plot a pie chart from json data in d3
- In d3js, how to plot line chart from csv file, taking data from seperate columns for each row
- Creating a line graph taking data from database
- d3 importing data from mysql database return "undefined"
- how to plot data from JSON object on .svg file using D3.js
- d3.js dynamic data from database
- reading data from Ruby in D3 (JSON)
More Query from same tag
- Adding react-d3 to my react-native app causes a error
- How to layout tree with fan-in in d3.js?
- python-nvd3 missing xAxis ticks
- Creating Markers for svg chart using d3.js
- Adding Zoom behavior to custom map points
- javascript check if file exists
- D3.js: How to adjust chord paths?
- d3 ticks only shows Sundays:
- How can I achieve the R kernel density estimate plot using D3.js?
- dc.js: Multiple graphs in a single dimension
- Zoom on multiple areas in d3.js
- Managing large hierarchical data (collapsible tree) with auto-zooming to the expanded node
- D3.js: Adding class whose name is based on data
- text labels are wrong in grouped bar chart d3js
- D3 Force Graph - Fixed Nodes that Don't Overlap
- D3 bar chart to stacked bar chart
- d3.js json http authentication issue (no data receive)
- dc.js LineChart Aggregated by Month/Year
- Remove black SVG fill in C3.js time-series chart
- How do I structure data in php to get the correct json result?
- Inline SVG with .html extension displays correctly, with .svg extension it doesn't
- 'd3 and 'd3-hexbin' in typescript as global libraries
- How to use a external JSON file instead of a hard coded JSON file in the HTML?
- JavaScript refresh file contents
- How can we create multi column table using multi array JSON using d3 and crossfilter javascript frameworks
- How do I make a custom axis formatter for hours & minutes in d3.js?
- Grouping nested dada
- Parsing Array for a Stacked Area Chart in D3
- d3.js Help getting Y axis dynamically labeled on simple bar chart
- Add circles to a line