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

Mixed chart type specification #4184

Closed
benmccann opened this issue Apr 26, 2017 · 2 comments
Closed

Mixed chart type specification #4184

benmccann opened this issue Apr 26, 2017 · 2 comments

Comments

@benmccann
Copy link
Contributor

The docs say for mixed chart type that the overall type must be bar (example from docs below). As a user, I don't understand this restriction.

  • What if I want to specify two lines? This seems to be possible. In this case, I can set the overall type as line and the docs appear to be wrong in saying that the type can only be "bar"
  • Why does my chart even have a type? This is redundant with the types specified in the dataset. If I have a bar and a line, but set the overall type to line then it breaks. This is strange and I don't understand the reason for it
 var myChart = new Chart(ctx, {
     type: 'bar',
     data: {
         labels: ['Item 1', 'Item 2', 'Item 3'],
         datasets: [
             {
                 type: 'bar',
                 label: 'Bar Component',
                 data: [10, 20, 30],
             },
             {
                 type: 'line',
                 label: 'Line Component',
                 data: [30, 20, 10],
             }
         ]
     }
 });
@etimberg
Copy link
Member

@benmccann good question! It actually works correctly for the opposite case, but the bar chart has some special default config to change how the x axis behaves (offsetGridline setting for instance) and only the default config of the overall type is merged.

I'm happy to look at a PR either updating the docs or finding a better merge strategy for the configs.
@simonbrunel thoughts?

In terms of your specific questions:
Each dataset that has type: 'line' will render as a line so multiple lines are possible

@benmccann
Copy link
Contributor Author

More details here: #4587

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

No branches or pull requests

3 participants