your cart

How to add reference line to a single continuous bar?

      In a real business world, sometimes you don't have a perfect data, but your boss may ask for a perfect format. I recently encounter this situation. Some categories only have data in recent years. But people want them show all years as other categories even no data.
      If I use discrete year, then will show as below:

      I have to change year to continuous to make all year show to meet user request:

      Then user ask to add a target line only on 2018 bar because they don't have target befoe 2018.
      If you just add a reference line on axis and even choose "Per Cell', it will cross whole pane because year is continuous.

      Let's use gantt bar to fix it. 
      First darg target to Rows and choose Dual Axis and synchronize it. Then change second axis to gantt chart and make size max.

      Then you will see line and bar not aligned if you choose bar chart size fixed.

      Then you need change bar size to manual, everything is fixed.
      You can check tableau workbook.

Blog Category