在ng2图表中重新编写chart.js功能

在ng2图表中重新编写chart.js功能,chart.js,ng2-charts,Chart.js,Ng2 Charts,我不熟悉Chart.js和ng2图表。我希望chart.js中的这个功能可以在ng2图表中重新编写。有可能吗 Chart.defaults.LineWithLine = Chart.defaults.line; Chart.controllers.LineWithLine = Chart.controllers.line.extend({ draw: function(ease) { Chart.controllers.line.prototype.draw.call(this,

我不熟悉Chart.js和ng2图表。我希望chart.js中的这个功能可以在ng2图表中重新编写。有可能吗

Chart.defaults.LineWithLine = Chart.defaults.line;
Chart.controllers.LineWithLine = Chart.controllers.line.extend({
  draw: function(ease) {
     Chart.controllers.line.prototype.draw.call(this, ease);

     if (this.chart.tooltip._active && this.chart.tooltip._active.length) {
      var activePoint = this.chart.tooltip._active[0],
          ctx = this.chart.ctx,
          x = activePoint.tooltipPosition().x,
          topY = this.chart.scales['y-axis-0'].top,
          bottomY = this.chart.scales['y-axis-0'].bottom;

       // draw line
       ctx.save();
       ctx.beginPath();
       ctx.moveTo(x, topY);
       ctx.lineTo(x, bottomY);
       ctx.lineWidth = 2;
       ctx.strokeStyle = '#07C';
       ctx.stroke();
       ctx.restore();
     }
  }
});

这是我的小提琴:

你可以用剪贴簿代替

下载:

现在可以使用此方法:(需要jquery)

在html标题中添加:

<script src="dist/clipboard.min.js"></script>

在html代码中添加:

<pre class="copytoclipboard">
    <code class="language-html">
        <h1>Hello world !</h1>
    </code>
</pre>


你好,世界!
在页脚中添加:

<script>
        /* Prism copy to clipbaord for all pre with copytoclipboard class */
        $('pre.copytoclipboard').each(function () {
            $this = $(this);
            $button = $('<button>Copy</button>');
            $this.wrap('<div/>').removeClass('copytoclipboard');
            $wrapper = $this.parent();
            $wrapper.addClass('copytoclipboard-wrapper').css({position: 'relative'})
            $button.css({position: 'absolute', top: 10, right: 10}).appendTo($wrapper).addClass('copytoclipboard btn btn-default');
            /* */
            var copyCode = new Clipboard('button.copytoclipboard', {
                target: function (trigger) {
                    return trigger.previousElementSibling;
                }
            });
            copyCode.on('success', function (event) {
                event.clearSelection();
                event.trigger.textContent = 'Copied';
                window.setTimeout(function () {
                    event.trigger.textContent = 'Copy';
                }, 2000);
            });
            copyCode.on('error', function (event) {
                event.trigger.textContent = 'Press "Ctrl + C" to copy';
                window.setTimeout(function () {
                    event.trigger.textContent = 'Copy';
                }, 2000);
            });
        });
</script>

/*使用copytoclipboard类将所有pre的棱柱复制到Clipboard*/
$('pre.copytoclipboard')。每个(函数(){
$this=$(this);
$button=$('Copy');
$this.wrap(“”).removeClass('copytoclipboard');
$wrapper=$this.parent();
$wrapper.addClass('copytolipboard-wrapper').css({position:'relative'})
$button.css({position:'absolute',top:10,right:10}).appendTo($wrapper.addClass('copytclipboard btn btn default');
/* */
var copyCode=新剪贴板('button.copytoclipboard'{
目标:功能(触发器){
返回trigger.previousElementSibling;
}
});
copyCode.on('success',函数(事件){
event.clearSelection();
event.trigger.textContent='Copied';
setTimeout(函数(){
event.trigger.textContent='Copy';
}, 2000);
});
copyCode.on('error',函数(事件){
event.trigger.textContent='按“Ctrl+C”复制';
setTimeout(函数(){
event.trigger.textContent='Copy';
}, 2000);
});
});
基于: