Phil
Phil

Reputation: 1

Setting the x-axis data labels to match the dates in a date column

In the following code, Vega Lite seems to auto assign x-axis labels that don't align with the data in the date column.

{
  "mark": "line",
  "encoding": {
    "x": {
      "field": "date",
      "type": "temporal",
      "timeUnit": "yearmonthdate",
      "axis": {
        "labelExpr": "timeFormat(datum.value, '%b %e')"
      }
    },
    "y": {
      "field": "value",
      "type": "quantitative"
    }
  },
  "data": {
    "values": [
      {"date": "2024-03-31", "value": 10}, 
      {"date": "2024-06-30", "value": 25},
      {"date": "2024-09-30", "value": 30},
      {"date": "2024-12-31", "value": 40}
    ]
  }
}

Given the dates in the dataset are month-end, anyone know how I can force the month-end dates to be displayed on the x-axis? For example, I have 'Mar-31-2024' in my data, but the x-axis label for that is 'Apr 1'.

https://i.sstatic.net/BOXOZ46z.png

Upvotes: 0

Views: 13

Answers (0)

Related Questions