Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Chart.helpers.extend(Chart.controllers.line.prototype, {
- draw: function () {
- originalLineDraw.apply(this, arguments);
- chart = this.chart;
- ctx = chart.chart.ctx;
- arr = chart.config.data.lineAtIndexGrouped;
- // console.log('outside', arr);
- if (arr) {
- xaxis = chart.scales['x-axis-0'];
- yaxis = chart.scales['y-axis-0'];
- for (var index in arr) {
- ctx.moveTo(xaxis.getPixelForValue(undefined, index), yaxis.top);
- ctx.strokeStyle = '#ff0000';
- ctx.lineTo(xaxis.getPixelForValue(undefined, index), yaxis.bottom);
- ctx.stroke();
- ctx.restore();
- }
- }
- },
- execute: function() {
- ctx.save();
- ctx.beginPath();
- ctx.font = "12px Arial";
- ctx.fillStyle = '#000';
- chartElement.mousemove(function(evt) {
- for (var index in arr) {
- if (evt.clientX - $(this).offset().left > xaxis.getPixelForValue(undefined, index) - 5
- && evt.clientX - $(this).offset().left < xaxis.getPixelForValue(undefined, index) + 5) {
- var counter = 0;
- arr[index].labels.forEach(function (el) {
- ctx.fillText(el, xaxis.getPixelForValue(undefined, index), yaxis.top + 20 + counter * 12);
- counter++;
- });
- } else {
- }
- }
- });
- }
- });
Advertisement
Add Comment
Please, Sign In to add comment