I'm loading in a csv file using D3 that by design doesn't have a header line. The data looks like this:
11,12,16,32,12
63,21,34,74,23
I've managed to load the data in and am plotting it using the D3 Parallel Coordinates module (syntagmatic.github.io/parallel-coordinates). However when plotting the axis names default to 0,1,2,3,4. I am trying to change these custom labels to labels read in from an additional file that contains the label names. I have no control over the data structure.
The code below shows two of my functions. The first converts data from a csv file path into a plottable format. The second is the actual plotting of that data. Is there anything I should be altering in order to specify custom axis lables?
// This function takes a file path and loads the data into a variable, then calls plot_data
function load_file(file) {
// removes previous SVG plots to prevent messy overlays and memory chaos
d3.selectAll("svg").remove();
// This code takes the file (which is a path, and puts it into var data, which is then given to the parcoords plot function)
d3.text(file, function(text) {
var data = d3.csv.parseRows(text).map(function(row) {
return row.map(function(value) {
return +value;
});
});
// This function plots the data given to it.
function plot_data(data) {
pc1 = d3.parcoords()("#example")
// This is how we get colour working. put a function in the parameters it iterates over each data item .color()
.data(data)
.render()
.alpha(0.35)
.brushMode("1D-axes")
.interactive() // command line mode
pc1.reorderable();
console.log("The plot should be done now")
};