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

Category pan #33

Merged
merged 17 commits into from
Sep 15, 2016
Merged

Category pan #33

merged 17 commits into from
Sep 15, 2016

Conversation

QuantumBob
Copy link
Contributor

Hi,

We recently messaged on slack.
Please consider these changes for the implementation of the category panning.
And please excuse the huge number of commits and the somewhat colourful messages.

Like I said in slack I am new to git, but now realize why you should think about your commit statements!

Copy link
Member

@etimberg etimberg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a good start. There are some minor issues that need to be addressed before merging.

@@ -0,0 +1 @@
start cmd /k "cd c:/xampp/htdocs/Chart.Zoom"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should probably not include this file in the main repo

@@ -132,7 +132,7 @@
mode: 'xy'
},
zoom: {
enabled: true,
enabled: false,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we shouldn't disable zoom in the zoom sample

},
zoom: {
enabled: true,
enabled: false,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file is zoom-bar.html. I think it would be best to create a new pan only bar sample pan-bar.html

var offsetAmt = Math.max((scale.ticks.length - ((scale.options.gridLines.offsetGridLines) ? 0 : 1)), 1);
var panSpeed = options.pan.speed;

console.log('panSpeed: ' + panSpeed);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please remove logging

@@ -145,10 +158,10 @@ function panNumericalScale(scale, delta) {
}
}

function panScale(scale, delta) {
function panScale(scale, delta, panSpeed) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

panSpeed should be options

@@ -159,7 +172,7 @@ function doPan(chartInstance, deltaX, deltaY) {

helpers.each(chartInstance.scales, function(scale, id) {
if (scale.isHorizontal() && directionEnabled(panMode, 'x') && deltaX !== 0) {
panScale(scale, deltaX);
panScale(scale, deltaX, helpers.getValueOrDefault(chartInstance.options, defaultOptions));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think its best to either pass chartInstance.options or panOptions here depending on if we want the pan method to have access to all the options or just the pan options. It might make sense to add a check further up that ensures the options are present so that we don't have to have all kinds of these checks everywhere (i'm fine with doing that in a separate pull request)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You had already done it!

function doPan(chartInstance, deltaX, deltaY) {
var panOptions = chartInstance.options.pan;
if (panOptions && helpers.getValueOrDefault(panOptions.enabled, defaultOptions.pan.enabled)) {
var panMode = helpers.getValueOrDefault(chartInstance.options.pan.mode, defaultOptions.pan.mode);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Noticed that this wasn't picking up the default pan speed if there wasn't one in the user options.
doPan() now sets panOptions.speed to either the user or default value before passing panOptions to panScale

@@ -343,6 +357,7 @@ var zoomPlugin = {
mc.on('panend', function(e) {
currentDeltaX = null;
currentDeltaY = null;
zoomNS.panCumulativeDelta = 0;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks like the spacing is different here according to GH

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure why. My copy looks lined up. Have deleted all indents and reset it with tabs

@QuantumBob
Copy link
Contributor Author

Hi,

I've done all the changes requested above.

You had already got the panOptions variable check in doPan.
Most of the other mistakes were silly 11pm shouldn't haves.
There is now a bar-pan.html sample with the speed option set in the options.

@QuantumBob
Copy link
Contributor Author

The indents in panIndexScale() don't match up with the rest.
It is annoying me but I haven't been able to fix it

@etimberg
Copy link
Member

Look good!

@etimberg etimberg merged commit fdc1cab into chartjs:master Sep 15, 2016
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

Successfully merging this pull request may close these issues.

2 participants