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

The chart does not appear when using the slider #11

Open
grandkarabas opened this issue Dec 14, 2017 · 0 comments
Open

The chart does not appear when using the slider #11

grandkarabas opened this issue Dec 14, 2017 · 0 comments

Comments

@grandkarabas
Copy link

When creating a chart with a slider, the chart is not displayed in a number of cases until the position of the slider is changed. I think this is due to the creation of two objects of Chart class within the same context (lines 3 and 29 of RangeSlider-core.js):

chartProto: new Chart(opts.chartCTX),
ranger.chart = new Chart(ctx, {

As far as I understand, the first object is created only in order to update width of the corresponding canvas element for the slider element to occupy the corresponding space. If this is the case, then the first Chart is not necessary to create, but instead move line 89 a little back before editing of css:

	ranger._create()

	ranger.sliderElement
		.addClass('range-slider')
		.css({
			width: opts.chartCTX.canvas.width - 50
		})

	//TODO: add rangeslider width adjustment
	$(window).on('resize', function () {
		ranger.sliderElement.css({
			width: opts.chartCTX.canvas.width - 50
		})
	})

	return ranger

In this case width of appropriate canvas element would be properly updated, so the width of the slider element will be the same as it was intended.
no-chart

grandkarabas pushed a commit to grandkarabas/Chart.js-RangeSlider that referenced this issue Dec 14, 2017
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