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

Issue with calculatedZoomMode and number of columns #405

Open
fsimic25 opened this issue Sep 11, 2024 · 0 comments
Open

Issue with calculatedZoomMode and number of columns #405

fsimic25 opened this issue Sep 11, 2024 · 0 comments

Comments

@fsimic25
Copy link

Describe the bug
When I'm generating config and initializing GSTC, if I have calculatedZoomMode set to true with correct config.chart.time.from and config.chart.time.to, and the number of columns is larger than 5 I get the error u.allDates[u.level] is not iterable,

If I use the same data for chart items and rows, and the number of columns is less than 5 then it loads. If i set calculatedZoomMode to false and custom zoom is used then it works. Also if i load the config with calculatedZoomMode on false, then I can update it to true and it works (loads chart data).

Code
Generate config with 10+ columns, and set calculatedZoomMode on true, and then supply it to constructor like this:

const config = this.generateConfig();

this.gstc = GSTC({
	element: this.gstcElement.nativeElement,
	state: GSTC.api.stateFromConfig(config)
});
	generateConfig(): Config {
		const rows = this.getRows(this.data);
		const items = this.getTimelineItems(this.data);
		const columns = this.getColumns(this.settings);
		const headerHeight = this.getHeaderHeight();
		const levels = this.getCalendarLevels();

		const self = this;

		const config: Config = {
			licenseKey: environment.calendarLicense,
			headerHeight: this.settings.header?.enabled ? headerHeight : 0,
			list: {
				rows,
				columns: {
					percent: 100,
					data: columns
				},
				expander: {
					padding: 10
				},
				toggle: {
					display: false
				}
			},
			chart: {
				items,
				calendarLevels: levels,
				time: {
					leftGlobal: undefined
				},
				grid: {
					cell: {
						onCreate: [this.onCellCreate]
					}
				}
			},
			plugins: [
				TimelinePointer(),
				Selection({
					events: {
						onEnd(selected) {
							// If we're not selecting any items, clear the selection
							if (selected?.['chart-timeline-items-row-item'].length < 1) {
								self.clearItemSelection();
							} else {
								self.toggleItemMovementState(true);
							}
							return selected;
						}
					}
				}),
				ItemResizing(this.getItemResizeOptions(this.gstc)),
				ItemMovement(this.getItemMovementOptions(this.gstc) as any),
				ExportImage()
			],
			scroll: {
				vertical: {
					precise: true
				},
				horizontal: {
					precise: true
				}
			},
			slots: {
				'chart-timeline-items-row-item': { content: [this.getItemSlot.bind(this)] }
			},
			version: '',
			actions: {
				chart: [this.createChartScrollAction.bind(this)],
				'list-column-row': [this.createColumnItemClickAction.bind(this)],
				'chart-timeline-items-row-item': [this.itemTippy.bind(this), this.createItemClickAction.bind(this)]
			}
		};

		if (
			this.settings?.calendarDateRange?.start &&
			this.settings?.calendarDateRange?.end &&
			Date.parse(this.settings?.calendarDateRange?.start) < Date.parse(this.settings?.calendarDateRange?.end)
		) {
			config.chart.time.from = GSTC.api.date(this.settings.calendarDateRange.start).valueOf();
			config.chart.time.to = GSTC.api.date(this.settings.calendarDateRange.end).valueOf();
		} else {
			const dateRange = this.getTableDateRange(this.data);
			config.chart.time.from = GSTC.api.date(dateRange.from).valueOf();
			config.chart.time.to = GSTC.api.date(dateRange.to).add(1, 'month').valueOf();
		}

		if (this.settings?.zoomLevel?.value) {
			config.chart.time.zoom = this.settings?.zoomLevel?.value;
			config.chart.time.calculatedZoomMode = false;
		} else {
			config.chart.time.calculatedZoomMode = true; // This causes bug, if there is more than 5 columns
		}

		if (this.settings.innerHeight) {
			config.innerHeight = this.settings.innerHeight;
		}

		return config;
	}

gantt-schedule-timeline-calendar version
What version are you using?
Version 3.20.1

Screenshots or movies

image

Columns that load data correctly:

image

Columns that cause the issue:

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant