question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Issue when use renderItem for Custom Series

See original GitHub issue

Version

5.1.1

Steps to reproduce

I use example at link : https://echarts.apache.org/examples/en/editor.html?c=custom-profile end edit with purpose exchange xaxis and yaxis. I only edit xaxis, yaxis, Endcode and renderItem:

var data = [];
var dataCount = 10;
var startTime =  new Date();
var categories = ['categoryA', 'categoryB', 'categoryC'];
var types = [
    {name: 'JS Heap', color: '#7b9ce1'},
    {name: 'Documents', color: '#bd6d6c'},
    {name: 'Nodes', color: '#75d874'},
    {name: 'Listeners', color: '#e0bc78'},
    {name: 'GPU Memory', color: '#dc77dc'},
    {name: 'GPU', color: '#72b362'}
];

// Generate mock data
categories.forEach(function (category, index) {
    var baseTime = startTime;
    for (var i = 0; i < dataCount; i  ) {
        var typeItem = types[Math.round(Math.random() * (types.length - 1))];
        var duration = Math.round(Math.random() * 10000);
        data.push({
            name: typeItem.name,
            value: [
                index,
                baseTime,
                baseTime  = duration,
                duration
            ],
            itemStyle: {
                normal: {
                    color: typeItem.color
                }
            }
        });
        baseTime  = Math.round(Math.random() * 2000);
    }
});

function renderItem(params, api) {
    var categoryIndex = api.value(0);
    var start = api.coord([ categoryIndex,api.value(1),]);
    var end = api.coord([ categoryIndex,api.value(2),]);
    var width = api.size([0, 1])[0] * 0.8;

    var rectShape = echarts.graphic.clipRectByRect({
        x: start[0] - width/2,
        y: start[1] ,
        width: width,
        height: end[1] - start[1]
    }, {
        x: params.coordSys.x,
        y: params.coordSys.y,
        width: params.coordSys.width,
        height: params.coordSys.height
    });

    return rectShape && {
        type: 'rect',
        transition: ['shape'],
        shape: rectShape,
        style: api.style()
    };
}

option = {
    tooltip: {
        formatter: function (params) {
            return params.marker   params.name   ': '   params.value[3]   ' ms';
        }
    },
    title: {
        text: 'Profile',
        left: 'center'
    },
    dataZoom: [{
        type: 'slider',
        filterMode: 'weakFilter',
        showDataShadow: false,
        top: 400,
        labelFormatter: ''
    }, {
        type: 'inside',
        filterMode: 'weakFilter'
    }],
    grid: {
        height: 300
    },
    xAxis: {
        data: categories
    },
    yAxis: {
        min: startTime,
        scale: true,
        axisLabel: {
            formatter: function (val) {
                return Math.max(0, val - startTime)   ' ms';
            }
        }
    },
    series: [{
        type: 'custom',
        renderItem: renderItem,
        itemStyle: {
            opacity: 0.8
        },
        encode: {
            y: [1, 2],
            x: 0
        },
        data: data
    }]
};

What is expected?

Chart will render on vertical

What is actually happening?

Chart is not rendered

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
pissangcommented, Jun 1, 2021

Why the + character in your code are all missing?

1reaction
echarts-bot[bot]commented, Jun 1, 2021

@Tuanlt17 Please provide a minimum reproducible demo for the issue either with https://codepen.io/Ovilia/pen/dyYWXWM , https://www.makeapie.com/editor.html or https://codesandbox.io/s/mystifying-bash-2uthz.

A minimum reproducible demo should contain as little data and components as possible but can still illustrate your problem. This is the best way for us to reproduce it and solve the problem faster.

Read more comments on GitHub >

github_iconTop Results From Across the Web

React-Native FlatList not re-rendering with custom renderItem
Show activity on this post. I had the same issue but resolved using extraData = {this.state}. Complete code is here <FlatList style={styles.
Read more >
[@types/echarts] renderItem in @types/echarts/options/series ...
It looks like the definition of renderItem of interface SeriesCustom just got parsed according to the Echarts documentation.
Read more >
A deep dive into React Native FlatList - LogRocket Blog
FlatList is a React Native component that allows you to render lists with zero hassle and minimal code. Learn how to customize FlatList....
Read more >
Displaying a List in React Native: Map Method or FlatList ...
The map method technically gives you more flexibility to customize your list ... The basic code to use FlatList with keyExtractor, data, and...
Read more >
Display a List Using the FlatList Component in React Native
renderItem requires a function that takes an item object as an input from the data source to construct and return a list-item component....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found