Skip to content

[BUG] Stacked bar using time axis without having the same datetime #5657

@stukdev

Description

@stukdev

Expected Behavior

Create a stacked bar using time axis with different datetime in the datasets. For example:

datasets: 
  [
    {
      label: 'A',
      data: 
      [
        {
          x: "01-01-2018",
          y: 12
        },
        {
          x: "02-01-2018",
          y: 15
        }, 
      ],
    },
    {
      label: 'B',
      data: 
      [
        {
          x: "02-01-2018",
          y: 23
        },
        {
          x: "03-01-2018",
          y: 34
        },
        {
          x: "04-01-2018",
          y: 45
        },
      ]
    }
  ],

In this example dataset B haven't the point at "01-01-2018"

Current Behavior

Currently, using the stacked bar with time axis need the datasets having the same point datatime even if some point is set to 0.

datasets: 
  [
    {
      label: 'A',
      data: 
      [
        {
          x: "01-01-2018",
          y: 12
        },
        {
          x: "02-01-2018",
          y: 15
        }, 
      ],
    },
    {
      label: 'B',
      data: 
      [
        {
          x: "01-01-2018",
          y: 0
        },
        {
          x: "02-01-2018",
          y: 23
        },
        {
          x: "03-01-2018",
          y: 34
        },
        {
          x: "04-01-2018",
          y: 45
        },
      ]
    }
  ],

Possible Solution

Calculate the height of the single bar looking for every datasets if the datetime is present or not

Steps to Reproduce (for bugs)

Here the problem on stackoverflow
Here the jsfiddle

Context

I want show the stacked bar without having to manipulate all the datasets for add the missing point.

Environment

  • Chart.js version: 2.7.2
  • Browser name and version: Firefox 61.0.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions