chartjs / chartjs-plugin-annotation

Annotation plugin for Chart.js
MIT License
603 stars 325 forks source link

update limited.md #803

Closed ghost closed 1 year ago

ghost commented 1 year ago

Should be an array of annotations and not an object

stockiNail commented 1 year ago

@jdaviesgla thank you for PR but the annotations can be set by an array but also by an object, therefore the sample is correct and the PR is not needed. Using the object, the annotation will have also the id, using the key of the object.

ghost commented 1 year ago

@stockiNail but this results in an object of objects?

It would take the form:

{{
  type: 'line',
  borderColor: 'green',
  borderWidth: 3,
  label: {
    display: true,
    backgroundColor: 'lightGreen',
    borderRadius: 0,
    color: 'green',
    content: 'Summer time'
  },
  arrowHeads: {
    start: {
      display: true,
      borderColor: 'green'
    },
    end: {
      display: true,
      borderColor: 'green'
    }
  },
  xMax: 8,
  xMin: 5,
  xScaleID: 'x',
  yMax: 110,
  yMin: 110,
  yScaleID: 'y'
}, {
  type: 'line',
  borderColor: 'green',
  borderDash: [6, 6],
  borderWidth: 1,
  xMax: 5,
  xMin: 5,
  xScaleID: 'x',
  yMax: 0,
  yMin: 110,
  yScaleID: 'y'
}}
stockiNail commented 1 year ago

The annotations object could have the following format:

annotations: {
  ann1: {
    type: 'line', 
    ....
  },
  ann2: {
    type: 'box', 
    ....
  }
  .....
  annN: {
    type: 'point', 
    ....
  }
}
ghost commented 1 year ago

@stockiNail I see - my bad!

ghost commented 1 year ago

@stockiNail thanks!

stockiNail commented 1 year ago

@jdaviesgla ur welcome! Thank you too!