Skip to content
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

override donsn't work as expected with type 'scatter' #19

Open
eloyvallinaes opened this issue Jun 30, 2020 · 3 comments
Open

override donsn't work as expected with type 'scatter' #19

eloyvallinaes opened this issue Jun 30, 2020 · 3 comments

Comments

@eloyvallinaes
Copy link

Setting specific colors for some traces in Chart of type 'scatter' doesn't prevent them for catching colors from the scheme. More exactly, even though the legend does show what would be expected, the markers on the canvas retain the colors supplied by the colorscheme.

MWE

        var myChart = new Chart(ctx, {
        type: 'scatter',
        data: {
          datasets: [
            {
             data : [
               {"x" : 10, "y" : 10},
               {"x" : 20, "y" : 20}
           ],
             backgroundColor : "gray",
             label : "Set 1"
           },
            {
              data : [
                {"x" : 10, "y" : 20},
                {"x" : 20, "y" : 40}
            ],
            label : "Set 2"
            }
          ]
          },
        options : {
          plugins : {
            colorschemes: {
              scheme: 'tableau.ColorBlind10',
              override : false,
              fillAlpha : 0.2
            }
          }
        }
      });

Output

image

@cvijanovicn
Copy link

any feedback on this? I have the same problem

@eloyvallinaes
Copy link
Author

eloyvallinaes commented Jul 17, 2020

A workaround is to set up these four dataset properties:

dataset : {
backgroundColor : "lightgray",
pointBackgroundColor : "lightgray",
borderColor : "white",
pointBorderColor : "white",
}

the BackgroundColor and BorderColor will set what's displayed on the legend, while pointBackgroundColor and pointBorderColor will set what you see on the plot. Hope that helps!

@cvijanovicn
Copy link

thanks,

what also helped me as a workaround is manually disabling plugin for specific chart:

options.plugins: {
colorschemes: false
}

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

No branches or pull requests

2 participants