-1

I'm a beginner when it comes to javascript and D3. I want to create a bubble chart using D3 and I need to get the data from an external file. I've searched for other ways but it looks like nothing works. Does anyone know how can I do it?

function animatedBubbleChart() {
    var bubbleChart = new d3.svg.BubbleChart({
        supportResponsive: true,
        size: 800,
        innerRadius: 600 / 3.5,
        radiusMin: 50,
        data: {
          items: [//replace this with data from a json
            {text: "2010", count: "170"},
            {text: "2011", count: "170"},
            {text: "2012", count: "170"},
            {text: "2013", count: "170"},
            {text: "2014", count: "170"},
            {text: "2015", count: "170"},
            {text: "2016", count: "170"},
          ],
          eval: function (item) {return item.count;},
          classed: function (item) {return item.text.split(" ").join("");}
        },
        plugins: [
          {
Gerardo Furtado
  • 100,839
  • 9
  • 121
  • 171
  • 1
    Well, this doesn't seem like a pure D3 code, there is some kind of plugin here. So, please edit your question showing us what's the plugin you're using, so you can get proper help. Also, I removed the snippet, it is for running code only. – Gerardo Furtado Jan 05 '18 at 23:31
  • 1
    What doesn't work? Is loading data the only issue? Please update your question to elaborate. – wahwahwah Jan 06 '18 at 01:27

1 Answers1

-1

You can use the d3.csv function Documentation Returns a new request for the CSV file at the specified url. This question has a good answer! LINK TO QUESTION example

d3.csv("test.csv", function (data) {    
    console.log(data[0]);
}

for json similarly

d3.json("test.json", function(data) {
  console.log(data[0]);
});

I would try and set up a fiddle so that people can better help you!

Tyler Cowan
  • 820
  • 4
  • 13
  • 35
  • not sure why I got a downvote, this is the correct answer, if asker could put up a fiddle Id append his work to reflect that.. – Tyler Cowan Jan 10 '18 at 15:26
  • I think he was asking how you could make an Ajax request then get parse the data in d3 chart. Same thing I am looking for – Sahil Mar 13 '20 at 12:19