-
Chris henryJuly 29, 2018 at 8:36 am #11326
Hello. My data is currently nested in a JSON file format. The Halo example uses CSV. How can I tailor it to my input? Or do I need to un-wrap it and convert to CSV?
vizulyJuly 29, 2018 at 8:44 am #11327Hello Chris,
Thank you for your question.
Ultimately, the Halo component consumes javascript objects, which can be sourced from either CSV or JSON. The example files are using CSV, but they convert that CSV into objects within the
halo_test.js loadData()
function using the d3.csv loader. Once d3 has converted the CSV it looks like this in a JSON format:[{"CMTE_ID":"C00018945","FILE_NUM":"723297","TRANSACTION_TP":"24K","Month":"1","Day":"13","Year":"2011","TRANSACTION_AMT":"2000","STATE":"MN","ENTITY_TYPE":"PAC","CAND_ID":"S6MN00267","CAND_NAME":"KLOBUCHAR, AMY J","OFFICE":"S","PTY":"DEM","Key":"S0","CMTE_NM":"DORSEY NATIONAL FUND"}, ... ]
This format is a transaction based row format, that the Halo component then aggregates and displays. You can easily use this format and the d3.json loader if your source data is in JSON.
You will want to adapt both the
loadData()
andinitialize()
functions to meet your specific data feed requirements. You will probably need to make some changes to your data structure in javascript to support this format. This is very typical of most data visualization components, where you need to write a little data adapter code to modify source formats into something a component can consume.I hope this helps.
Cheers,
Tom
-
|
You must be logged in to reply to this topic.