Skip to content

Commit

Permalink
Fixed a Javascript error if the user attempts to drag a box annotation
Browse files Browse the repository at this point in the history
  • Loading branch information
compwright committed Nov 18, 2016
1 parent 42b3d31 commit 51b2016
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
12 changes: 11 additions & 1 deletion samples/draggable-line.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<title>Scatter Chart</title>
<script src="../node_modules/chart.js/dist/Chart.bundle.js"></script>
<script src="../node_modules/chartjs-plugin-annotation/chartjs-plugin-annotation.min.js"></script>
<script src="../dist/chartjs-plugin-draggable.min.js"></script>
<script src="../dist/chartjs-plugin-draggable.js"></script>
<style>
canvas {
-moz-user-select: none;
Expand Down Expand Up @@ -151,6 +151,16 @@
content: "This is a another test label"
},
draggable: true
},
{
type: 'box',
xScaleID: 'x-axis-1',
yScaleID: 'y-axis-1',
xMin: 25,
xMax: 45,
yMin: 25,
yMax: 45,
borderWidth: 4
}]
}
}
Expand Down
4 changes: 3 additions & 1 deletion src/accessor.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
'use strict';

import { DraggableElement } from './element';

export class DraggableElementAccessor {
static isSupported() {
return true;
Expand All @@ -12,7 +14,7 @@ export class DraggableElementAccessor {

return elements
.map((element, i) => {
let className = elementClassFn(configs[i]);
let className = elementClassFn(configs[i]) || DraggableElement;
return new className(chartInstance, element, configs[i]);
})
.filter((element, i) => !!configs[i].draggable);
Expand Down
3 changes: 1 addition & 2 deletions src/annotation/accessor.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@ export class DraggableAnnotationAccessor extends DraggableElementAccessor {
case 'line':
return DraggableLineAnnotationElement;

default:
throw `Unsupported annotation type: ${config.type}`;
// @TODO: implement 'box' support, DraggableBoxAnnotationElement class
}
}
);
Expand Down

0 comments on commit 51b2016

Please sign in to comment.