Coder Social home page Coder Social logo

Comments (8)

entronad avatar entronad commented on May 14, 2024

@lyyb2001
If you want to register an action to an event, please try something like:

extraScript: '''
  chart.on('click', (params) => {
    chart.dispatchAction({
      type:'highlight',
      seriesIndex: 1,
      dataIndex: 0
    });
  });
''',

from flutter_echarts.

lyyb2001 avatar lyyb2001 commented on May 14, 2024

@lyyb2001
If you want to register an action to an event, please try something like:

extraScript: '''
  chart.on('click', (params) => {
    chart.dispatchAction({
      type:'highlight',
      seriesIndex: 1,
      dataIndex: 0
    });
  });
''',

I mean triggered at initialization, not in response to a user's click event

There are two kinds of events in echarts, one is the mouse event, which will be triggered when clicking a figure, and the other is the event triggered after calling dispatchaction

from flutter_echarts.

entronad avatar entronad commented on May 14, 2024

@lyyb2001
The extraScript is executed before any chart.setOption ( I set this order because we don't know when the real setOption happens in async cases.).
I think this is why your dispatchAction didn't work, for in that time the was no option in the chart.
I have a hack idea, you can wrap your dispatchAction in an async function (setTimeout, etc.) to let it execute after your setOption, like:

extraScript: '''
  setTimeout(() => {
    chart.dispatchAction(...);
  }, 0);
''',

from flutter_echarts.

lyyb2001 avatar lyyb2001 commented on May 14, 2024

@lyyb2001
The extraScript is executed before any chart.setOption ( I set this order because we don't know when the real setOption happens in async cases.).
I think this is why your dispatchAction didn't work, for in that time the was no option in the chart.
I have a hack idea, you can wrap your dispatchAction in an async function (setTimeout, etc.) to let it execute after your setOption, like:

extraScript: '''
  setTimeout(() => {
    chart.dispatchAction(...);
  }, 0);
''',

Thank you very much for your answer,i tried,but it still doesn't work!
my code is:
final String options = '''
{
animation: false,
grid: {
top: 70,
},
tooltip: {
trigger: 'axis'
},
toolbox: {
show: true
},
legend: {
y: 'bottom',
data:['Normal']
},
xAxis: {
type: 'category',
data: ['3-18','3-19','3-20','3-21','3-22']
},
yAxis: {
type: 'value',
minInterval: 1
},
series: [{
name: 'Normal',
data: [10,20,30,20,10],
type: 'line',
smooth: true,
itemStyle : {
normal : {
color:'#000000',
}
}
},
]
}
''';

Echarts(
option: options,
extraScript: '''
setTimeout(() => {
chart.dispatchAction({
type:'highlight',
seriesIndex: 0,
dataIndex: 0
});
},3000);
''',
)

from flutter_echarts.

entronad avatar entronad commented on May 14, 2024

@lyyb2001
Does it work in a web echarts project?

from flutter_echarts.

lyyb2001 avatar lyyb2001 commented on May 14, 2024

I'm sorry I made a mistake,Actually, I need to ‘showTip' effect,but i use 'highlight',So without careful observation, the effect is not obvious 。Thank you again for your reply 。This issue can be closed

from flutter_echarts.

entronad avatar entronad commented on May 14, 2024

@lyyb2001

By the way, dose it work without the setTimeout or must wrap in the setTimeout?

from flutter_echarts.

sanrixue avatar sanrixue commented on May 14, 2024

tooltip 触发方法后 需要 隐藏 但无法隐藏的问题

tooltip 中 自定义 点击操作 触发以下方法

          setTimeout(()=> {
          chart.dispatchAction(
            {
            type: 'hideTip'
          }
          );
            Messager.postMessage(JSON.stringify({
                      params:params,
                }));    
          },3000);

flutter 端可以接收到post过来的数据 但是 tooltip 不可以隐藏

from flutter_echarts.

Related Issues (20)

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.