0

I'm trying to load local csv file and also use a timeseries. I have lots of data so I'm getting it from csv (url: 'data_testing.csv') but I also want to use a time series with 12 hours interval and the total interval is 5 days. I tried many things but with no luck. It seems like I either have to use data from the same script (not loading a csv) in order to use timeseries. I'm able to load the CSV, but once I add the timeseries, it does not work anymore. I'm also able to use a timeseries but only if the data is from the columns and not from a file load. I need to work both, timeseries + data from CSV file.

C3 version: 0.6.8 - D3 version: 5.7.0 - Browser: Chrome - OS: Mac OSX

var chart = c3.generate({
bindto: '#chart',
data: {
    // this only works if I don't use time series
    url: '../data_testing.csv',
    x: 'x',
    // this only works if I'm writing the data and not using local csv file
    xFormat: '%Y-%m-%d',
    columns: [
        ['x', '2016-8-10', '2016-8-10', '2016-8-10', '2016-8-10', '2016-8-10', '2016-8-10']
    ],
    type: 'line'

  },

axis: {
    x: {
        type: 'timeseries',
        localtime: false,
        tick: {
            culling: true,
            fit: true,
            culling: {
                max: window.innerWidth > 700 ? 8 : 5
            },
            format: '%Y-%m-%d' // %H:%M:%S
        }
    },
    y: {
        max: 55,
        min: 6
    }
}
  });

require(["d3", "c3"], function (d3, c3) {
      c3.generate({

   });
  });
o-az
  • 397
  • 2
  • 10
  • Are there any errors appearing in your F12 window console? I am not sure but I wonder if there is a cross-origin or similar issue. Chrome has a thing about using local files - see https://stackoverflow.com/questions/39007243/cannot-open-local-file-chrome-not-allowed-to-load-local-resource – Vanquished Wombat Nov 05 '18 at 07:32
  • @VanquishedWombat I'm able to load the CSV file with no problems. It's only when I add the time series it stops displaying the loaded file – o-az Nov 05 '18 at 14:44
  • Looking at samples on c3.js website I think that data.URL and data.columns may be mutually exclusive. You might be able to add the time series in the chart.onrendered() event - [see this example[(https://c3js.org/samples/data_load.html) which is not precisely what you need because it is always the same plot type, but may help show the way. – Vanquished Wombat Nov 06 '18 at 12:08

0 Answers0