Skip to content

Categorical legend for bubble chart renders incorrectly when category has only 1 value #2833

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
lwhite1 opened this issue Jul 23, 2018 · 3 comments · Fixed by #2840
Closed
Labels
bug something broken

Comments

@lwhite1
Copy link

lwhite1 commented Jul 23, 2018

The size of one of the points associated with the scale is too large. It seems to be rendering at the same size as the value it represents. This is the only category that has a single value, which may be a factor.

newplot 1

The code is here.

<html>
<head>
    <script src="https://cdn.plot.ly/plotly-latest.min.js"></script>
</head>
<body>
    <div id='target' style="width:600px;height:450px;"></div>
    <script>

        var target_target = document.getElementById('target');
        var layout = {
    title: 'Average retail price for champagnes by year and rating',
    height: 600,
    width: 800,
    showlegend: true,
    xaxis: {
    title: 'highest pro score',
    },
    yaxis: {
    title: 'year',
    },

};

var trace0 =
{
x: ['90.0','91.0','90.0','89.0','91.0','90.0','90.0','91.0','90.0','89.0','93.0','87.0','90.0','90.0'],
y: [1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 2.0, 9.0, 10.0, 11.0, 6.0, 2.0],
showlegend: true,
marker: {
    size: [21.995, 32.99, 26.99, 20.99, 27.99, 21.8405, 28.475, 22.99, 21.69, 26.8655, 29.99, 24.74, 21.8405, 26.99],
},
mode: 'markers',
type: 'scatter',
name: 'Carneros',
};
var trace1 =
{
x: ['93.0'],
y: [1.0],
showlegend: true,
marker: {
    size: 74.99,
},
mode: 'markers',
type: 'scatter',
name: 'Central Coast',
};
var trace2 =
{
x: ['91.0','93.0','93.0','93.0','94.0','90.0','93.0','87.0','93.0','93.0','87.0','88.0','87.0','87.0','92.0'],
y: [1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 3.0, 8.0, 3.0, 3.0, 9.0, 10.0, 10.0, 11.0],
showlegend: true,
marker: {
    size: [29.495, 27.995, 19.99, 39.48, 54.99, 35.49, 57.99, 14.99, 56.99, 28.99, 38.49, 31.49, 33.99, 35.49, 77.49],
},
mode: 'markers',
type: 'scatter',
name: 'Napa Valley',
};

        var data = [ trace0, trace1, trace2];
Plotly.newPlot(target_target, data, layout);
    </script>
</body>
</html>
@lwhite1
Copy link
Author

lwhite1 commented Jul 23, 2018

In further testing, the plot renders correctly if the size is treated as an array, even if it contains a single value. In other words, this works

marker: {
    size: [74.99],
},

although this does not:

marker: {
    size: 74.99,
},

If this is the expected behavior, please close.
EDIT
Treating the single value as a one element array as shown above, only works if there is one element in the corresponding data arrays. If you use an array and there is more than one point to draw, only the first point will be rendered. I believe that the original issue is therefore an actual bug.

@etpinard
Copy link
Contributor

Thanks a bug. Thanks!

@etpinard etpinard added the bug something broken label Jul 23, 2018
@etpinard
Copy link
Contributor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug something broken
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants