I am trying to create multiple line charts from an array of objects but having difficulty of understanding how to bind the data and create the Y and X axes correctly.
Below is a shortened version of the data that I am working with:
var prices = [{
"pagination": {
"count": 6,
},
"data": [
{
"open": 9.67,
"close": 9.98,
"volume": 17876279,
"symbol": "WISH",
"date": "2021-08-05T00:00:00+0000"
},
{
"open": 10.3,
"close": 9.61,
"volume": 34099145,
"symbol": "WISH",
"date": "2021-08-04T00:00:00+0000"
},
{
"open": 10.36,
"close": 10.31,
"volume": 20379283,
"symbol": "WISH",
"date": "2021-08-03T00:00:00+0000"
}
]
},
{
"pagination": {
"count": 6,
},
"data": [
{
"open": 27.3,
"close": 28.33,
"volume": 2360664,
"symbol": "CRSR",
"date": "2021-08-05T00:00:00+0000"
},
{
"open": 26.83,
"close": 27.4,
"volume": 4409156,
"symbol": "CRSR",
"date": "2021-08-04T00:00:00+0000"
},
{
"open": 26.99,
"close": 27.13,
"volume": 8675462,
"symbol": "CRSR",
"date": "2021-08-03T00:00:00+0000"
}
]
}]
And this is what I have done so far in creating the line charts
var priceMargin = {top: 10, right: 30, bottom: 30, left: 60},
priceWidth = 460 - priceMargin.left - priceMargin.right,
priceHeight = 400 - priceMargin.top - priceMargin.bottom;
var priceSvg = d3.selectAll(".company-price")
.data(prices, function(d){
return d.data
})
.append("svg")
.attr("width", priceWidth + priceMargin.left + priceMargin.right)
.attr("height", priceHeight + priceMargin.top + priceMargin.bottom)
.append("g")
.attr("transform", "translate(" + priceMargin.left + "," + priceMargin.top + ")")
My goal is to create a line chart for every object inside the array that consists of its own range of values for the Y(close) and X(dates) axes inside separate ".company-price" div container, but not sure how create the X-axis and Y-axis and access the data that was passed in above. Below is a screenshot of my HTML structure and the goal I would like to achieve
Any help or advice would be greatly appreciated!

