c3js / c3js/c3

change axis when loading new data dynamically

Open
#1,258 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
9.3k
Forks
1.4k
Avg merge
6d 16h
Merged PRs (30d)
1

Description

Hey guys,
So I am new to json but I have made some good progress.

So I am loading data into an area-spline with a timeseries as the x axis in the form of %Y-%m-%d as shown below

var chart = c3.generate({
bindto: '#missed-calls',
data: {
x: 'time',
type:"area-spline",
colors: {
missedcall: '#0000ff'
},
url: '',
mimeType: 'json',
names:{missedcall:"Missed calls"}
},
axis: {
x: {type: 'timeseries', tick:{format: '%Y-%m-%d'}}
}
});

I am then loading new data dynamically via json when there is a change in frequency, say weekly, monthly or daily as shown below

$("#dashboard-data").on("change",function(e)
{
missedcall_.load({
url: '/dashboard/recent_data/missed_calls/',
mimeType: 'json'
});
});

The x axis timeseries format hence becomes irrelevant as I need it to change from %Y-%m-%d to %m or something iike that..
I am loading the necessary data from json but I do not know how to effect the change of the x axis on the dynamically loaded data..

Where do I place this code to effect the new axis

axis: {
x: {type: 'timeseries', tick:{format: '%Y-%m-%d'}}
}
}

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.