Skip to content

Commit

Permalink
Fix the issue that extra elements are rendered
Browse files Browse the repository at this point in the history
- This fixes #2.
  • Loading branch information
nagix committed Sep 28, 2018
1 parent 863debf commit c1a59aa
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions src/helpers/helpers.style.js
Expand Up @@ -2,6 +2,8 @@

export default function() {

var OFFSET = 100000000;

return {
drawBackground: function(view, drawCallback) {
var borderWidth = view.borderWidth;
Expand All @@ -23,19 +25,18 @@ export default function() {

drawShadow: function(chart, offsetX, offsetY, blur, color, drawCallback, backmost) {
var ctx = chart.ctx;
var offset = chart.width;
var pixelRatio = chart.currentDevicePixelRatio;

ctx.save();

ctx.shadowOffsetX = (offsetX + offset) * pixelRatio;
ctx.shadowOffsetX = (offsetX + OFFSET) * pixelRatio;
ctx.shadowOffsetY = offsetY * pixelRatio;
ctx.shadowBlur = blur * pixelRatio;
ctx.shadowColor = color;
if (backmost) {
ctx.globalCompositeOperation = 'destination-over';
}
ctx.translate(-offset, 0);
ctx.translate(-OFFSET, 0);

drawCallback();

Expand All @@ -52,7 +53,6 @@ export default function() {

drawBevel: function(chart, width, highlightColor, shadowColor, drawCallback) {
var ctx = chart.ctx;
var offset = chart.width;
var pixelRatio = chart.currentDevicePixelRatio;
var shadowOffset = (width * pixelRatio) / 2;

Expand All @@ -64,13 +64,13 @@ export default function() {
ctx.clip();

// Make stencil
ctx.translate(-offset, 0);
ctx.translate(-OFFSET, 0);
this.setPath(ctx, drawCallback);
ctx.rect(0, 0, chart.width, chart.height);

// Draw bevel shadow
ctx.fillStyle = 'black';
ctx.shadowOffsetX = offset * pixelRatio - shadowOffset;
ctx.shadowOffsetX = OFFSET * pixelRatio - shadowOffset;
ctx.shadowOffsetY = -shadowOffset;
ctx.shadowBlur = shadowOffset;
ctx.shadowColor = shadowColor;
Expand All @@ -83,7 +83,7 @@ export default function() {
ctx.fill('evenodd');

// Draw Bevel highlight
ctx.shadowOffsetX = offset * pixelRatio + shadowOffset;
ctx.shadowOffsetX = OFFSET * pixelRatio + shadowOffset;
ctx.shadowOffsetY = shadowOffset;
ctx.shadowColor = highlightColor;
ctx.fill('evenodd');
Expand All @@ -93,7 +93,6 @@ export default function() {

drawGlow: function(chart, width, color, borderWidth, drawCallback, isOuter) {
var ctx = chart.ctx;
var offset = chart.width;
var pixelRatio = chart.currentDevicePixelRatio;

if (!width) {
Expand All @@ -110,7 +109,7 @@ export default function() {
ctx.clip('evenodd');

// Set path
ctx.translate(-offset, 0);
ctx.translate(-OFFSET, 0);
this.setPath(ctx, drawCallback);
if (!isOuter) {
ctx.rect(0, 0, chart.width, chart.height);
Expand All @@ -120,7 +119,7 @@ export default function() {
ctx.lineWidth = borderWidth;
ctx.strokeStyle = 'black';
ctx.fillStyle = 'black';
ctx.shadowOffsetX = offset * pixelRatio;
ctx.shadowOffsetX = OFFSET * pixelRatio;
ctx.shadowBlur = width * pixelRatio;
ctx.shadowColor = color;
ctx.fill('evenodd');
Expand Down

0 comments on commit c1a59aa

Please sign in to comment.