kurkle / chartjs-plugin-gradient

Easy gradients for Chart.js
MIT License
37 stars 6 forks source link

Fix missing compatibility with CHART.JS version 2.x #19

Closed stockiNail closed 2 years ago

stockiNail commented 2 years ago

The PR # 16 introduced a breaking change, removing the support of version CHART.JS 2.x. This PR is fixing it.

kurkle commented 2 years ago

I think a new helper would be good (to resolve the code smell too):

const parse = Chart.version 
  ? (scale, value) => scale.parse(value) 
  : (scale, value) => value;

function scaleValue(scale, value) {
  const normValue = isNumber(value) ? parseFloat(value) : parse(scale, value);
  return scale.getPixelForValue(normValue);
}
stockiNail commented 2 years ago

I think a new helper would be good (to resolve the code smell too):

I haven't seen your post. I do now.

stockiNail commented 2 years ago

@kurkle just FYI, including the CHART parts, the check on Chart.version was useless because the plugin finds always the chart version to 3.5.0, the version included. Therefore it never worked with version 2.x of CHART.JS.

sonarcloud[bot] commented 2 years ago

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

stockiNail commented 2 years ago

de facto, this PR is not solving the compatibility with version 2 because it didn't work anyway, but, together with PR #18, it is solved.

stockiNail commented 2 years ago

FYI, I have tested the master and now it works both 3.x and 2.x !!! :ok_hand: :satisfied: