David
David

Reputation: 569

chart js data-point between bar charts

I'm working of Chart.js library. I wanted to add data-pointer on bar charts. attaching the example image here.. enter image description here

Tried a lot to implement this. But couldn't get option in chart js. Can anyone please help me out here ?

Upvotes: 3

Views: 2352

Answers (1)

beaver
beaver

Reputation: 17647

Two options with Chart.js:

1. using data labels plugin:

    plugins: {
      datalabels: {
        color: 'red',
        align: 'top',
        anchor: 'end',
        formatter: function(value, context) {
            console.log(context)
            if (value>70)
            return "("+context.dataIndex + '): ' + value;
          else
            return "";
        }
      }
    }

example: http://jsfiddle.net/beaver71/wo2cd3jf/

2. using annotation plugin:

    annotation: {
         drawTime: 'afterDatasetsDraw',
         annotations: annotations_array
    }

example: https://jsfiddle.net/beaver71/esnjuqzv/

Upvotes: 4

Related Questions