<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: PaykomanVll</title>
    <description>The latest articles on DEV Community by PaykomanVll (@paykoman).</description>
    <link>https://dev.to/paykoman</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1354156%2F75d36081-035b-41ab-8f96-2c7e86a6c5a8.png</url>
      <title>DEV Community: PaykomanVll</title>
      <link>https://dev.to/paykoman</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/paykoman"/>
    <language>en</language>
    <item>
      <title>[Apache echart] Add an item to graph but exclude from pie</title>
      <dc:creator>PaykomanVll</dc:creator>
      <pubDate>Fri, 15 Mar 2024 08:23:33 +0000</pubDate>
      <link>https://dev.to/paykoman/apache-echart-add-an-item-to-graph-but-exclude-from-pie-2ohi</link>
      <guid>https://dev.to/paykoman/apache-echart-add-an-item-to-graph-but-exclude-from-pie-2ohi</guid>
      <description>&lt;p&gt;Hello,&lt;/p&gt;

&lt;p&gt;found your great and powerfull echart plugin, now i have to do a simple chart and i spend a lot of hours to find the right configuration but every solution i found have any problem :(&lt;/p&gt;

&lt;p&gt;I use the default template for a pie with 4 lines with a graph below.&lt;/p&gt;

&lt;p&gt;Now i want just to add one simple bar to show avg BUT the AVG has ben excluded from the pie me and a friend we can't find a working configuration :(&lt;/p&gt;

&lt;p&gt;At least we working with a sourc.map and filter but the collors then are wrong, we are use defined colors but will not work and be overwritten =(&lt;/p&gt;

&lt;p&gt;My code:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;var myChart = echarts.init(document.getElementById('testchart')),
option = {
    // theme: 'dark', // not working how we can toogle darkmode ?
    legend: {
        data: ['LvL 3','LvL 4','LvL 5','LvL 6','AVG']
    },
    tooltip: {
      trigger: 'axis',
      showContent: false
    },
    dataset: {
      source: [
        ['horses', '9/23', '10/23', '11/23', '12/23', '1/24', '2/24'],
        ['LvL 3', 56.5, 82.1, 88.7, 70.1, 53.4, 85.1],
        ['LvL 4', 51.1, 51.4, 55.1, 53.3, 73.8, 68.7],
        ['LvL 5', 40.1, 62.2, 69.5, 36.4, 45.2, 32.5],
        ['LvL 6', 25.2, 37.1, 41.2, 18, 33.9, 49.1],
        ['AVG', 8.0, 7.3, 7.9, 8.6, 9.6, 9.6]
      ]
    },
    xAxis: { type: 'category' },
    yAxis: { gridIndex: 0 },
    grid: { top: '55%' },
    series: [
     {
        name: 'LvL 3',
        type: 'line',
        smooth: true,
        seriesLayoutBy: 'row',
        emphasis: { focus: 'series' }
      },{
        name: 'LvL 4',
        type: 'line',
        smooth: true,
        seriesLayoutBy: 'row',
        emphasis: { focus: 'series' }
      },{
        name: 'LvL 5',
        type: 'line',
        smooth: true,
        seriesLayoutBy: 'row',
        emphasis: { focus: 'series' }
      },{
        name: 'LvL 6',
        type: 'line',
        color: '#ee6666',
        smooth: true,
        seriesLayoutBy: 'row',
        emphasis: { focus: 'series' }
      },{
        name: 'AVG',
        type: 'bar',
        color: 'pink', // color in pie is blue and not pink -,-
        smooth: true,
        seriesLayoutBy: 'row',
        emphasis: { focus: 'series' },
        label: {
          show: true,
          position: 'top',
          valueAnimation: true
        }
      },{
        type: 'pie',
        id: 'pie',
        radius: '30%',
        center: ['50%', '25%'],
        emphasis: {
          focus: 'self'
        },
        label: {
          formatter: '{b}: {@9/23} ({d}%)'
        },
        encode: {
          itemName: 'horses',
          value: '9/23',
          tooltip: '9/23'
        },
      }
    ]
  };

myChart.on('updateAxisPointer', function(event){
  const xAxisInfo = event.axesInfo[0];
  if (xAxisInfo) {
    const dimension = xAxisInfo.value + 1;
    // const source = option.dataset.source.filter(row =&amp;gt; row[0] !== 'AVG');
    // const newData = source.map(row =&amp;gt; ({
    //   name: row[0],
    //   value: row[dimension]
    // }));

    myChart.setOption({
      series: [{
        id: 'pie',
        // data: newData
        label: {
            formatter: '{b}: {@[' + dimension + ']} ({d}%)'
        },
        encode: {
        value: dimension,
        tooltip: dimension
        }
      }]
    });
  }
});
myChart.setOption(option);

//   function initializePieChart(){
//     const initialDimension = 1; 
//     const source = option.dataset.source.filter(row =&amp;gt; row[0] !== 'AVG');
//     const newData = source.map(row =&amp;gt; ({
//       name: row[0],
//       value: row[initialDimension]
//     }));

//     myChart.setOption({
//       series: [{
//         id: 'pie',
//         // data: newData
//       }]
//     });
//   }

//   initializePieChart();
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I hope anyone can help me =(&lt;/p&gt;

&lt;p&gt;Thank you&lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
