OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

Disable item individually (pieChart - ECHARTS)

  • Thread starter Thread starter neves
  • Start date Start date
N

neves

Guest
I tried to disable an option individually in pieChart (ECHARTS) but it doesn't work, neither with silent nor even within itemStyle, whether normal or with emphasis. I need to disable one (or more) slices of the graph, but using the data componentType, to be able to access it later through an event, like:

Code:
myChartUse.on("click", ...)

Full code:


Code:
const myChartUse = echarts.init(document.getElementById("myChart"));

const option = {

  series: [{
    type: "pie",
    selectedMode: "single",
    selectedOffset: 10,
    // disable all items , but I need to disable it individually in data
    //silent: true,
    data: [{
      name: "Name 1",
      value: 30
    }, {
      name: "Name 2",
      value: 50,
      silent: true
      // or itemStyle: {silent: true}
    }, {
      name: "Value3",
      value: 20
    }]
  }]

}

myChartUse.setOption(option);

Code:
<head>
  <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/echarts.min.js"></script>
</head>

<div id="myChart" style="width: 700px; height: 600px;"></div>


  • I know that the documentation does not list silent to be used in series.data, but to explain my problem, this argument is what best fits to explain my problem.


  • Using opacity in itemStyle is not interesting as it is still possible to trigger events on the item (e.g. mouseenter).

I tried this:

Code:
myChartUse.dispatchAction({
  type: 'unselect',
  seriesIndex: 0,
  dataIndex: 1
});

But it does not work.

<p>I tried to disable an option individually in pieChart (ECHARTS) but it doesn't work, neither with <code>silent</code> nor even within <code>itemStyle</code>, whether <code>normal</code> or with <code>emphasis</code>. I need to disable one (or more) slices of the graph, but using the <code>data</code> componentType, to be able to access it later through an event, like:</p>
<pre><code>myChartUse.on("click", ...)
</code></pre>
<p>Full code:</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>const myChartUse = echarts.init(document.getElementById("myChart"));

const option = {

series: [{
type: "pie",
selectedMode: "single",
selectedOffset: 10,
// disable all items , but I need to disable it individually in data
//silent: true,
data: [{
name: "Name 1",
value: 30
}, {
name: "Name 2",
value: 50,
silent: true
// or itemStyle: {silent: true}
}, {
name: "Value3",
value: 20
}]
}]

}

myChartUse.setOption(option);</code></pre>
<pre class="snippet-code-html lang-html prettyprint-override"><code><head>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/echarts.min.js"></script>
</head>

<div id="myChart" style="width: 700px; height: 600px;"></div></code></pre>
</div>
</div>
</p>
<ul>
<li><p>I know that the documentation does not list <code>silent</code> to be used in <code>series.data</code>, but to explain my problem, this argument is what best fits to explain my problem.</p>
</li>
<li><p>Using <code>opacity</code> in <code>itemStyle</code> is not interesting as it is still possible to trigger events on the item (e.g. mouseenter).</p>
</li>
</ul>
<p>I tried this:</p>
<pre><code>myChartUse.dispatchAction({
type: 'unselect',
seriesIndex: 0,
dataIndex: 1
});
</code></pre>
<p>But it does not work.</p>
 

Latest posts

A
Replies
0
Views
1
Ashrik Ahamed
A
A
Replies
0
Views
1
Ashrik Ahamed
A

Online statistics

Members online
1
Guests online
4
Total visitors
5
Top