Comments (6)
@entronad
OK. My temporary solution is to use Opacity to make Echarts invisiable, and waiting a tick when Echarts starts to render, after that making Echarts visiable.
Opacity(
opacity: opacity,
child: Container(
child: Echarts(
key: chartKey,
onMessage: (emsg) {
if(emsg == 'rendered') {
if(opacity == 0) { // wait the render of chart
Future.delayed(Duration(milliseconds: 50), () {
opacity = 1;
setState({});
// or bloc.add();
});
}
}
},
extraScript: '''
chart.on('rendered', () => {
Messager.postMessage('rendered');
});
''',
from flutter_echarts.
This is caused by the forced white background of webview in webview_flutter plugin. Now we don't have any workaround to avoid the white blink before the chart is loaded. Many people are following this issue of webview_flutter: flutter/flutter#29300
We hope this will be fixed soon.
这是由于 webview_flutter 强制 webview 的背景颜色为白色(而不是透明),
目前没有好的办法解决因此导致的加载完成前一瞬间的白色,很多人也在跟进 webview_flutter 的这个问题:flutter/flutter#29300
希望在下个版本中会改进
from flutter_echarts.
@blackredscarf
Dose this work on iOS?
We have thought about this way, but according to my experiment and this user's case: #18 (comment) , echarts dosen't work well in Opacity.
from flutter_echarts.
@entronad
I only test it on Android now. I will have a try on iOS in a few months later.
from flutter_echarts.
Wrapping chart with opacity doesn't work for me on iOS. A workaround I found until flutter/plugins#3431 is merged is to use stack & cover the chart until is starts to render.
Stack(
children: [
Echarts(
option: data,
onMessage: (message) {
if (opacity == 1) {
setState(() {
opacity = 0.0;
});
}
},
extraScript: '''
chart.on('rendered', function () {
Messager.postMessage('chart rendered');
});
''',
),
Opacity(
opacity: opacity,
child: Container(
color: Colors.black,
width: MediaQuery.of(context).size.width,
height: MediaQuery.of(context).size.height,
),
)
],
);
from flutter_echarts.
You don't need opacity. Simply show a Container on top of a chart with an "if" statement. For example,
bool _hideChart = true;
static const String _extraScript = '''
chart.on('rendered', function () {
Messager.postMessage('chart rendered');
});
''';
...
return Stack(
children: [
Echarts(
option: _dataString,
extraScript: _hideChart ? _extraScript : null,
onMessage: (message) {
if (mounted && _hideChart) {
setState(() {
_hideChart = false;
});
}
},
),
if (_hideChart)
Container(
color: Colors.black,
width: MediaQuery.of(context).size.width,
height: MediaQuery.of(context).size.height,
),
],
);
This way you don't render an unnecessary widget with every refresh of a chart.
from flutter_echarts.
Related Issues (20)
- App crashes to load
- Code srevh
- webview_flutter ^4.0.1 no match HOT 5
- Unsupported operation:Trying to use the default webview implementation for TargetPlatfom.windows butthere isnt a default one See also: https://flutter.dev/docs/testing/errors HOT 1
- 请升级下依赖,比如webview_flutter,谢谢 HOT 2
- Safari is not markPoint compatible
- 界面back的时候flutter_echarts执行了clearCache操作,每次都会报错
- Using svg file
- 使用gauge仪表盘,界面显示空白。请问是什么原因,如何修改
- 在下面这段使用到flutter_echarts的代码中,tooltips里formatter的onclick填入什么样的方法,才能在onMessage中获取到数据?
- Convert Flutter Echarts to pdf from flutter APP HOT 1
- Chart Freeze when we have a more than 1000 data points
- 各位大佬 WebView.destroy() called while WebView is still attached to window 这问题是怎么解决的。。。 HOT 4
- How to use flutter echarts component loading a China map has city location, require a demo.
- Recently change error, Come from javaScript resource.Please solve it in original resource.Thanks. HOT 2
- 安卓设备报错 HOT 1
- Web Added
- 这库有极大的适配问题就不该去写出来的,早就该关闭了, HOT 1
- when running the example, there are some issues
- ios 刷新数据,统计图不在当前屏出现白屏
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 flutter_echarts.