kurkle / chartjs-plugin-gradient

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

Add support to time scale with colorStop option configured with formatted dates #16

Closed stockiNail closed 2 years ago

stockiNail commented 2 years ago

Fix #15.

This PR is enable the feature to use in color node color stop as formatted date, leveraging on scale parsing.

Example:

gradient: {
  backgroundColor: {
    axis: 'x',
      colors: {
        "05/30/2021": 'green',
        "06/02/2021": 'blue',
        "06/04/2021": 'red'
      }
    }
  }
}

Time scale options:

scales: {
  x: {
    type: 'time', 
    time: {
      unit: 'day',
      parser: 'MM/dd/yyyy',
    }
  }
}

timeGradient

stockiNail commented 2 years ago

let me rebase

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

This PR is also enabling the colorStop at relative index on labels for category axes.

Instead of using the label, you can use the index of the label adding adjustment, like:

gradient: {
  backgroundColor: {
    axis: 'x',
      colors: {
        "0": 'green', // position of label at index 0
        "2.5": 'blue', // position of the label between labels at index 2 and 3
        "8.5": 'red' // position of the label between labels at index 8 and 9
      }
    }
  }
}
stockiNail commented 2 years ago

@kurkle thank you very much for quick approval and merge. Now I can start working to import the plugin in my lib. ;)

kurkle commented 2 years ago

I'll delay the release though, because I'd like to add some docs and samples before that. Maybe call it 1.0 too.

stockiNail commented 2 years ago

I'll delay the release though,

Take your time. Because I have to develop the java wrappers and do all tests, I'm going to starting working with my fork and the file created locally. I'll change when new version will be published.

because I'd like to add some docs and samples before that.

Even if I'm busy (but luckily I can still work in multi threading...) maybe I can help you somehow. Let me know.

Maybe call it 1.0 too.

Vote for it!