I'm trying to replicate a similar diagram using dynamic input data. Here is a basic example of how I'm attempting to achieve this:
<script>
var myYears = ', 1991, 1992, 1993, 1994, 1995, 1998'; //auto-generated
var myValues = ', 1, -3, -6, -5, 2, -3'; //auto-generated
var textJSON = '{' +
'"data": {' +
'"x": "year",' +
'"columns": [' +
' ["year"' + myYears +'],' +
' ["value"' + myValues +']' +
' ],' +
'"type": "bar"' +
'}' +
'}' ;
var c3JSON = JSON.parse(textJSON);
var chart = c3.generate( c3JSON );
</script>
Everything works fine until I try to incorporate the color function into my text. It seems that parsing it to JSON format doesn't work as expected.
Has anyone encountered a similar issue or knows how to correctly include the color function in the JSON object?