C3.js Exclude Columns From Csv
I am creating a multiple series line graph with C3.JS by loading the data from a provided CSV file. I can plot the graph however I have not found yet if it is possible to only plot
Solution 1:
Inspired by @Armani I've ended up doing this, which is a combination of using d3.csv function with c3, as I didn´t find a way to do it with c3 URL.
- First I used D3 to load the CSV file into a JSON object
- Modify the data as required (not filtering)
- Feed C3 with the json object
- Use the "keys" property inside the c3 call to only show the fields I want.
d3.csv( _dataPath, function ( d ) {
var data = d;
if ( configdata.axis.x.source_units == "meses" && configdata.axis.x.units == "años" )
{
data[ configdata.axis.x.property_key ] = data[ configdata.axis.x.property_key ] / 12;
}
return data;
}, function( error, data ) {
if (!error)
{
var percentiles = [];
configdata.percentilesData.forEach( function( p ) {
percentiles.push( p.name );
});
var x_axis_label = configdata.axis.x.label + ' (' + configdata.axis.x.units + ')';
var y_axis_label = configdata.axis.y.label + ' (' + configdata.axis.y.units + ')';
var chart = c3.generate({
bindto: '#chart',
data: {
json: data,
type: 'line',
keys: {
x: configdata.axis.x.property_key,
value: percentiles
}
},
axis: {
y: {
label: y_axis_label
},
x: {
label: x_axis_label
}
},
tooltip: {
show: false
},
point: {
show: false
}
});
}
});
<scriptsrc="https://cdnjs.cloudflare.com/ajax/libs/d3/3.4.11/d3.min.js"></script>
Post a Comment for "C3.js Exclude Columns From Csv"