Giter VIP home page Giter VIP logo

Comments (8)

QJesus avatar QJesus commented on July 23, 2024 3
public initialize(options?: fabric.IChartConfiguration) {
	super.initialize(options);
	this.__createChart();
	this.__bindChartEvents();

	this.on('scaling', debounce(this.__setChartSize.bind(this), 5));
+	this.on('scaled', _ => {
+		const config = {
+			width: Math.ceil(this.width * this.scaleX),
+			height: Math.ceil(this.height * this.scaleY),
+			scaleX: 1.0,
+			scaleY: 1.0,
+		};
+		Object.keys(config).forEach(k => this.set.apply(this, [k, config[k]]), this);
+		this.__setChartSize.bind(this);
+	});

	return this
}

from chart-js-fabric.

yassilah avatar yassilah commented on July 23, 2024

Hi! Glad you like the package. Can you simply try to add a currentChart.set('dirty', true) after setting the data? The package does not force a re-render after updating the data unless you specifically request it.

from chart-js-fabric.

pnbao avatar pnbao commented on July 23, 2024

Hi @yassipad,
Thank you for your tip 🤩 It can render new data smoothly now 👍🏻
By the way, I also have faced a problem with chart scaling.

When I try to scale the chart, it sometimes renders a blank object. I think it relates to the responsive and maintainAspectRatio options, I have to set these options to true but not working properly. Do you have any idea? 😄

Screen Recording 2021-03-31 at 11 13 58

from chart-js-fabric.

yassilah avatar yassilah commented on July 23, 2024

This is a bit odd but unfortunately i think it's probably related to the number of rendering requests when scaling... Is cache disabled ?

from chart-js-fabric.

pnbao avatar pnbao commented on July 23, 2024

I have set the objectCaching: true when creating the chart but still face the same problem.

from chart-js-fabric.

pnbao avatar pnbao commented on July 23, 2024

Thank you @QJesus, it works amazingly! 😄

from chart-js-fabric.

mshameer237 avatar mshameer237 commented on July 23, 2024

@QJesus @pnbao Hi, Can you tell me what exactly the above code by @QJesus does? I am facing the same blank object issue on scaling.

from chart-js-fabric.

QJesus avatar QJesus commented on July 23, 2024

after scaled, resize width, height and scaleX/Y equals 1, chat cannot be scaled

can change Object.keys(config).forEach(k => this.set.apply(this, [k, config[k]]), this); to this.set(config)

from chart-js-fabric.

Related Issues (5)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.