| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116 |
- var myChart;
- var domGraphic = document.getElementById('graphic');
- var domMain = document.getElementById('main');
- var domMessage = document.getElementById('wrong-message');
- var iconResize = document.getElementById('icon-resize');
- var needRefresh = false;
- var enVersion = location.hash.indexOf('-en') != -1;
- var hash = location.hash.replace('-en','');
- hash = hash.replace('#','') || (needMap() ? 'default' : 'macarons');
- hash += enVersion ? '-en' : '';
- var curTheme;
- function requireCallback (ec, defaultTheme) {
- curTheme = themeSelector ? defaultTheme : {};
- echarts = ec;
- refresh();
- window.onresize = myChart.resize;
- }
- var themeSelector = $('#theme-select');
- if (themeSelector) {
- themeSelector.html(
- '<option selected="true" name="macarons">macarons</option>'
- + '<option name="infographic">infographic</option>'
- + '<option name="shine">shine</option>'
- + '<option name="dark">dark</option>'
- + '<option name="blue">blue</option>'
- + '<option name="green">green</option>'
- + '<option name="red">red</option>'
- + '<option name="gray">gray</option>'
- + '<option name="helianthus">helianthus</option>'
- + '<option name="roma">roma</option>'
- + '<option name="mint">mint</option>'
- + '<option name="macarons2">macarons2</option>'
- + '<option name="sakura">sakura</option>'
- + '<option name="default">default</option>'
- );
- $(themeSelector).on('change', function(){
- selectChange($(this).val());
- });
- function selectChange(value){
- var theme = value;
- myChart.showLoading();
- $(themeSelector).val(theme);
- if (theme != 'default') {
- window.location.hash = value + (enVersion ? '-en' : '');
- require(['theme/' + theme], function(tarTheme){
- curTheme = tarTheme;
- setTimeout(refreshTheme, 500);
- })
- }
- else {
- window.location.hash = enVersion ? '-en' : '';
- curTheme = {};
- setTimeout(refreshTheme, 500);
- }
- }
- function refreshTheme(){
- myChart.hideLoading();
- myChart.setTheme(curTheme);
- }
- if ($(themeSelector).val(hash.replace('-en', '')).val() != hash.replace('-en', '')) {
- $(themeSelector).val('macarons');
- hash = 'macarons' + enVersion ? '-en' : '';
- window.location.hash = hash;
- }
- }
- function autoResize() {
- if ($(iconResize).hasClass('glyphicon-resize-full')) {
- focusCode();
- iconResize.className = 'glyphicon glyphicon-resize-small';
- }
- else {
- focusGraphic();
- iconResize.className = 'glyphicon glyphicon-resize-full';
- }
- }
- function focusGraphic() {
- // domCode.className = 'col-md-4 ani';
- domGraphic.className = 'col-md-8 ani';
- if (needRefresh) {
- myChart.showLoading();
- setTimeout(refresh, 1000);
- }
- }
- function refresh(isBtnRefresh){
- if (isBtnRefresh) {
- needRefresh = true;
- focusGraphic();
- return;
- }
- needRefresh = false;
- if (myChart && myChart.dispose) {
- myChart.dispose();
- }
- myChart = echarts.init(domMain, curTheme);
- window.onresize = myChart.resize;
- // (new Function(editor.doc.getValue()))();
- myChart.setOption(option, true)
- domMessage.innerHTML = '';
- }
- function needMap() {
- var href = location.href;
- return href.indexOf('map') != -1
- || href.indexOf('mix3') != -1
- || href.indexOf('mix5') != -1
- || href.indexOf('dataRange') != -1;
- }
|