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

fix: preserve data updates to fill() when called with an argument #393

Open
wants to merge 1 commit into
base: master
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
9 changes: 8 additions & 1 deletion src/CalHeatmap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import Navigator from './calendar/Navigator';
import CalendarPainter from './calendar/CalendarPainter';
import Populator from './calendar/Populator';
import Options from './options/Options';
import type { DataRecord } from './options/Options';
import DataFetcher from './DataFetcher';
import DomainCollection from './calendar/DomainCollection';
import DateHelper from './helpers/DateHelper';
Expand Down Expand Up @@ -207,7 +208,7 @@ export default class CalHeatmap {
* @return A Promise, which will fulfill once all the underlying asynchronous
* tasks settle, whether resolved or rejected.
*/
fill(dataSource = this.options.options.data.source): Promise<unknown> {
fill(dataSource?: DataRecord[] | string): Promise<unknown> {
const { options } = this.options;
const template = this.templateCollection;
const endDate = this.dateHelper.intervals(
Expand All @@ -216,6 +217,12 @@ export default class CalHeatmap {
2,
)[1];

if (dataSource == null) {
this.options.options.data.source = dataSource;
} else {
dataSource = this.options.options.data.source;
}

const dataPromise = this.dataFetcher.getDatas(
dataSource,
this.domainCollection.min,
Expand Down