Component to generate HEX colors based on a strings. If a color has been used before by a different string, a new color will be generated that will be distinct from the previous one.
-
Include the library into your application:
<script src="lib/color-calculator.js"></script>
-
Create a new instance of the ColorCalculator:
let colorCalculator = new Moonbird.Component.ColorCalculator();
-
If desired, define a condition to generate a highlight based on start of string (will be shown in more yellow-red tones):
colorCalculator.registerStringToHighlight("Highlight");
-
Generate a color based on a given string:
let color = colorCalculator.generate("Highlight is just a word"); // will be highlighted
let color = colorCalculator.generate("The highlight is not the start"); // will not be highlighted
See the demo for a sample.
Component to provide colors and line styles to be used e.g. in charts. The same values will always use the same colors and styles.
See the demo for a sample and usage.
Please note: The shown CSS styles are just for illustration and not complete.