hurunjiu commented on issue #10415: Uncaught ReferenceError: app is not defined URL: https://github.com/apache/incubator-echarts/issues/10415#issuecomment-490410214 Firstly please declare variable "var app = {};" at the top . And then the main problem is the official example lacks a piece of code, which is the setup code for dat.gui. So please download "dat.gui.min.js" from https://github.com/dataarts/dat.gui (you can find this js under the build folder) introduce this component like this <script type =“text / javascript”src =“js / dat.gui.min.js”> </ script> and under this code : `app.config = { xAxis: 'protein', yAxis: 'calcium', onChange: function () { console.log("调用改变"); if (data) { myChart.setOption({ xAxis: { name: app.config.xAxis }, yAxis: { name: app.config.yAxis }, series: { data: data.map(function (item, idx) { return [ item[fieldIndices[app.config.xAxis]], item[fieldIndices[app.config.yAxis]], item[1], idx ]; }) } }); } } }; app.configParameters = { xAxis: { options: fieldNames }, yAxis: { options: fieldNames } };` Add: `var gui; if (gui) { $(gui.domElement).remove(); gui.destroy(); gui = null; } gui = new dat.GUI(); if (app.config) { /*gui = new dat.GUI({ autoPlace: false });*/ $(gui.domElement).css({ //position: 'absolute',//应用后就看不到close controls,出现了滚动条 right: 5, top: 0, zIndex: 1000 }); //$('.right-container').append(gui.domElement); $('.container').append(gui.domElement); var configParameters = app.configParameters || {}; for (var name in app.config) { var value = app.config[name]; if (name !== 'onChange' && name !== 'onFinishChange') { var isColor = false; // var value = obj; var controller; if (configParameters[name]) { if (configParameters[name].options) { controller = gui.add(app.config, name, configParameters[name].options); } else if (configParameters[name].min != null) { controller = gui.add(app.config, name, configParameters[name].min, configParameters[name].max); } } if (typeof obj === 'string') { try { var colorArr = echarts.color.parse(value); isColor = !!colorArr; if (isColor) { value = echarts.color.stringify(colorArr, 'rgba'); } } catch (e) {} } if (!controller) { controller = gui[isColor ? 'addColor' : 'add'](app.config, name); } app.config.onChange && controller.onChange(app.config.onChange); app.config.onFinishChange && controller.onFinishChange(app.config.onFinishChange); } } }` At the end . Please double-pig girl does not forget remove the comment "data = normalizeData(originData).slice(0, 1000);" And then you can solve the problem!
---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected] With regards, Apache Git Services --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
