Giter Club home page Giter Club logo

vb-color-functions-for-expressions's Introduction

VB-Color-Functions-For-Expressions

Inspired by functions avaliable in other BI tools, this is some lightweight function snippets to put into SQL Server Reporting Services and other VB applications. All of the function in this script will return only Hex Color Codes as String, e.g. #F0ADFF. The color function can then be easily fed into expressions.

Related Resources

More on colour model
Applying the code on SSRS, or if you want a more graphical guide

Function List

ColorMix

ColorMix ( Value, MaxValue, MinValue, MaxValueColor [, MinValueColor] )
A function that will interpolate intermediate colours between 2 specified colours according to value provided. Can be used to create gradient colour scales for heatmap.

Parameters Type Optional Description
Value Double No The value to be evaluated over MaxValue and MinValue, usually between MaxValue and MinValue. Values that overshoot the range will be truncated.
MaxValue Double No The value that correspond to MaxValueColor. Value larger than MaxValue will gives color that specified in MaxValueColor. The closer the value gets to the MaxValue supplied, the closer the color to MaxValueColor.
MinValue Double No The value that correspond to MinValueColor or white. Works pretty the same (or opposite) to MaxValue, and should be smaller than the MaxValue.
MaxValueColor String No The Hex Colour Code for the colour that correspond to MaxValue. Example #20ADFF.
MinValueColor String Yes The Hex Colour Code for the colour that correspond to MinValue. If no value is supplied, the MinValue will correspond to white #FFFFFF).

ColorMix2

ColorMix2 ( Value, MaxValue, MinValue, MaxValueColor , MinValueColor [, MidValueColor] )
A function that will interpolate intermediate colours between 3 specified colours according to value provided. Can be used to create gradient colour scales with 2 sides for heatmaps or other plots (e.g. blue-white-red). It is just a two-sided version of the ColorMix() function.

Parameters Type Optional Description
Value Double No The value to be evaluated over MaxValue and MinValue. Values that overshoot the range will be truncated. If value falls between MaxValue and the middle of MaxValue and MinValue, a ColorMix between Max and Mid Colour (default white) will be returned.
MaxValue Double No The value that correspond to MaxValueColor. Value larger than MaxValue will gives color that specified in MaxValueColor. The closer the value gets to the MaxValue supplied, the closer the color to MaxValueColor.
MinValue Double No The value that correspond to MinValueColor or white. Works pretty the same (or opposite) to MaxValue.
MaxValueColor String No The Hex Colour Code for the colour that correspond to MaxValue. Example #20ADFF.
MinValueColor String No The Hex Colour Code for the colour that correspond to MinValue. Example #AAD3FF.
MidValueColor String Yes The Hex Colour Code for the colour that correspond to MidValue. If no value is supplied, the MidValue will correspond to white #FFFFFF).

RBG

RGB ( red, blue, green)
Converts a RGB color code into Hex Colour Code that can be used by applications as expressions.

Parameters Type Optional Description
red Double No Between 0 and 255. Non integral value will be rounded off and values that overshoot will be truncated. Represents the numerical value for red.
green Double No Same as above (but green).
blue Double No Same as above (but blue).

HSL

HSL ( hue, saturation, lightness)
Converts a HSL color code into Hex Colour Code that can be used by applications as expressions.

Parameters Type Optional Description
hue Double No Between 0 and 1. Represents the degree of hue. Expecting to be larger than or equal to 0 and smailler than 1.
saturation Double No Between 0 and 1. Saturation of the colour. Values taht overshoot will be truncated.
lightness Double No Between 0 and 1. Lightness of the colour. Values that overshoot will be truncated.

HSV

HSV ( hue, saturation, value)
Converts a HSL color code into Hex Colour Code that can be used by applications as expressions.

Parameters Type Optional Description
hue Double No Between 0 and 1. Represents the degree of hue. Expecting to be larger than or equal to 0 and smailler than 1.
saturation Double No Between 0 and 1. Saturation of the colour. Values taht overshoot will be truncated.
value Double No Between 0 and 1. Value (Bightness) of the colour. Values that overshoot will be truncated.

HSL360, HSV360

HSL360 ( hue, saturation, lightness)
HSV360 ( hue, saturation, value)
Allows HSL and HSV to be called with values that ranged in [0,360) , [0,100] and [0,100] respectively that will make some users to feed parameters more coveniently.

RandomColor,

RandomColor ()
Return a random colour that is evenly distributed over the RGB color space.
RandomColorHSL ()
Return a random colour that is evenly distributed over the HLS color space.
RandomColorHSV ()
Return a random colour that is evenly distributed over the HSV color space.\

vb-color-functions-for-expressions's People

Contributors

streppyo avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.