How to display time on the y-axis of chart C3

Is it possible to display time in the y axis of diagram c3. I am using the code below, but the y axis time is not displayed. The x axis should be a category, and the y axis should be time.

var chart2 = c3.generate({
              bindto: '#predPerformance',
              data: {
                columns: [
                  ['01-11-2015', 1448287450, 1448287450, 1448287450, 1448287450, 1448287450, 1448287450, 1448287450 ],
                  ['02-11-2015', 1448291104, 1448291104, 1448291104, 1448291104, 1448291104, 1448291104, 1448291104 ]
                ]
              },
              axis: {
                x: {
                  categories: ['ABC', 'PQR', 'WWW', 'POINT', 'ETA','RTA','BLY'],
                  type: 'categorized'
                }
              },              
            axis: {
                y: {
                    type: 'timeseries'
                }
            }
            });  
+4
source share
2 answers

Try the axis: rotated property as shown in the code below: -

axis: {
  rotated: true
}

http://c3js.org/samples/timeseries.html

+1
source

I formatted the y axis and disabled the tooltip because the minute range is 0-59, but still the y axis is a range of values ​​(0-99). So I used a custom tooltip to convert a range of values ​​to a range of time.

var chart = c3.generate({
    data: {
        columns: [
            ['data1',201510210120, 201510210150, 201510210120, 201510210130,201510210135,201510210150],
            ['data2',201510210125, 201510210200, 201510210130, 201510210140,201510210155,201510210150],
            ['data3',201510210130, 201510210140, 201510210140, 201510210150,201510210125,201510210200]
        ]
    },
    size: {
            height: 320
          },
    axis: {

        x: {
            type: 'category',
            categories: ['ABC', 'PQR', 'WWW', 'POINT', 'ETA','RTA']
        },
        y: {
            tick: {
            //format: d3.format('$,')
            format: function (d) { return d.toString().substr(8, 2) + ':' + d.toString().substr(10, 2); }
            },
            max: 201510212300,
                    min: 201510210100
        }
    },
    tooltip: {
      show: false
    }
});
0
source

Source: https://habr.com/ru/post/1617085/


All Articles