Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add optional param to update to customize the responsiveOptions #1129

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/scripts/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,10 @@
* @param {Object} [data] Optional data you'd like to set for the chart before it will update. If not specified the update method will use the data that is already configured with the chart.
* @param {Object} [options] Optional options you'd like to add to the previous options for the chart before it will update. If not specified the update method will use the options that have been already configured with the chart.
* @param {Boolean} [override] If set to true, the passed options will be used to extend the options that have been configured already. Otherwise the chart default options will be used as the base
* @param {Array} [responsiveOptions] Optional array of responsive option arrays which are a media query and options object pair => [[mediaQueryString, optionsObject],[more...]]
* @memberof Chartist.Base
*/
function update(data, options, override) {
function update(data, options, override, responsiveOptions) {
if(data) {
this.data = data || {};
this.data.labels = this.data.labels || [];
Expand All @@ -35,6 +36,10 @@
});
}

if(responsiveOptions) {
this.responsiveOptions = responsiveOptions;
}

if(options) {
this.options = Chartist.extend({}, override ? this.options : this.defaultOptions, options);

Expand Down