Comments (3)
I can call the animateData function now in the listeners but when I add duration , it can add the bar scale but not trigger the smooth animation.
the updated code is :
import React, { Component } from 'react'
import styles from './style.scss'
import style from './style.css'
import AmCharts from 'amcharts3-react'
import jsonData from './data.js'
// #10
import 'amcharts3/amcharts/serial'
import 'amcharts3-animate'
class BarChartTest extends Component {
constructor (props) {
super(props)
this.state = { num: 100 }
this.onClick = this.onClick.bind(this)
}
onClick () {
this.setState({ num: this.state.num + 20 })
}
render () {
const data = [{
date: 0,
value: 100
}]
function update (event) {
event.chart.animateData(data, {
duration : 1000,
complete : function () {
data[0].value += 50;
setTimeout(update(event) , 500);
}
})
}
const config = {
'type': 'serial',
'theme': 'light',
'dataProvider': data,
// 'startDuration': 1,
'addClassNames' : true,
'graphs': [{
id: 'g1',
valueField: 'value',
title: 'value',
type: 'column',
fillAlphas: 0.9,
valueAxis: 'a1',
legendPeriodValueText: 'total: [[value.sum]] mi',
lineColor: '#263138',
alphaField: 'alpha'
}],
'valueAxes': [{
'minimum': -100,
'maximum': 500
}],
'chartCursor': {},
'zoomOutOnDataUpdate': false,
'listeners' : [{
'event' : 'init',
'method' : update
}],
'categoryField': 'date'
}
return (
<div className={styles.barChart}>
<AmCharts {...config} ref={(ref) => { this.chartRef = ref }} />
<div className={styles.scrollmenu} />
<button onClick={this.onClick}>add</button>
</div>
)
}
}
export default BarChartTest
thx a lot
from amcharts3-react.
use function in listener
and using event.chart.function
from amcharts3-react.
@bleachdugu I'm sorry for taking so long to get back to you on this.
As explained on the animate plugin page, you must first copy the dataProvider
before calling animateData
In addition, you were calling update(event)
immediately. Instead, you must wrap it in function () {}
so that it is delayed for 500 milliseconds.
Here is the correct code:
let data = [{
date: 0,
value: 100
}]
function update (event) {
data = JSON.parse(JSON.stringify(data));
data[0].value += 50;
event.chart.animateData(data, {
duration : 1000,
complete : function () {
setTimeout(function () {
update(event);
}, 500);
}
})
}
from amcharts3-react.
Related Issues (20)
- There is no horizontal scroll HOT 3
- Facing "this.legend.destroy is not a function" when component unmounts HOT 2
- Images are not visible HOT 1
- Issue in reconstructing amcharts in React HOT 1
- on
- Uncaught TypeError: Cannot read property 'capture' of undefined HOT 1
- color changin HOT 1
- valueAxes is not working for X axis HOT 1
- when to release amcharts4-react HOT 2
- d.AmStockChart is not a constructor HOT 1
- Test cases failing: ReferenceError: AmCharts is not defined HOT 1
- How do I use methods if I use JSX? HOT 1
- Does AmCharts support react native HOT 1
- Custom ID to AmCharts HOT 1
- Line with lower value is appearing above the others HOT 1
- How to update config for amChart4 HOT 1
- is it available to set a colums / options for exporting csv?
- chart.removeListener is not a function after upgrade the Webpack 4 to 5
- Support for react v17.x in peerDependencies HOT 1
- separate tooltip texts for columns and bullets in AmCharts 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from amcharts3-react.