Skip to content

Commit

Permalink
fix(flip events): support flip for events
Browse files Browse the repository at this point in the history
  • Loading branch information
yassilah committed Sep 18, 2020
1 parent 901e416 commit 4f9e024
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/chart-js-fabric.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import fabricJS, { fabric } from 'fabric'
import Chart, { ChartConfiguration, ChartSize } from 'chart.js'
import { merge } from 'lodash'
import { debounce, merge } from 'lodash'

const CHART_OPTIONS = 'chart'
const CHART_INSTANCE = '__chart'
Expand Down Expand Up @@ -46,7 +46,6 @@ export class ChartObject extends fabricObject {
*/
public _set(key: string, value: any) {
if (key === CHART_OPTIONS) {
console.log(key, value, this[CHART_OPTIONS])
return this.__setChartConfiguration(value)
}

Expand Down Expand Up @@ -211,11 +210,10 @@ export class ChartObject extends fabricObject {
)

if (this.flipX) {
x -= this.getScaledWidth()
x = this.getScaledWidth() - x
}

if (this.flipY) {
y -= this.getScaledHeight()
y = this.getScaledHeight() - y
}

this[CHART_INSTANCE].canvas!.dispatchEvent(
Expand Down Expand Up @@ -252,7 +250,7 @@ export class ChartObject extends fabricObject {
super.initialize(options)
this.__createChart()
this.__bindChartEvents()
this.on('scaling', this.__setChartSize.bind(this))
this.on('scaling', debounce(this.__setChartSize.bind(this), 5))

return this
}
Expand Down

0 comments on commit 4f9e024

Please sign in to comment.