npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

colored-average

v0.8.6

Published

Angular directive that allows you to dynamically colorize table cells based on the range of numeric values within the columns.

Downloads

4

Readme

colored-average Directive (Angular)

npm License

The colored-average directive is an Angular directive that allows you to dynamically colorize table cells based on the range of numeric values within the columns. You can specify minimum and maximum colors, and the directive will apply colors smoothly between them based on the values in the table.

colored-average Example1 colored-average Example2

Installation

You can install the colored-average directive via npm using the following command:

npm install colored-average

Usage

To use the colored-average directive, follow these steps:

  1. Import the ColoredAverageModule in your Angular module:

    import { NgModule } from '@angular/core';
    import { BrowserModule } from '@angular/platform-browser';
    import { ColoredAverageModule } from 'colored-average';
    
    import { AppComponent } from './app.component';
    
    @NgModule({
      declarations: [AppComponent],
      imports: [BrowserModule, ColoredAverageModule],
      providers: [],
      bootstrap: [AppComponent],
    })
    export class AppModule {}
  2. Import the ColoredAverageOptions in your Angular component:

    import { Component } from '@angular/core';
    import { ColoredAverageOptions } from 'colored-average';
    
    @Component({
      selector: 'app-your-component',
      templateUrl: './your-component.component.html',
    })
    export class YourComponent {
      coloredAverageOptions: ColoredAverageOptions = {
        minColor: '#FF0000', // Minimum color (e.g., red)
        maxColor: '#00FF00', // Maximum color (e.g., green)
        applyToBackground: true, // Apply to cell background color
        columnOptions: [
          {
            index: 3, // Index of the column (0-based)
            minValue: 0, // Minimum value for this column
            maxValue: 100, // Maximum value for this column
          },
          // Add more columnOptions as needed
         ],
      };
    }
  3. Add the [colored-average] directive to your table's tbody element in your component's template:

    <table>
        <tbody [colored-average]="coloredAverageOptions">
            <!-- Your table rows here -->
        </tbody>
    </table>

Now, the colored-average directive will apply color gradients to the table cells based on the numeric values within the columns.

Options

The ColoredAverageOptions interface allows you to customize the behavior of the directive:

  • minColor: The color applied to the minimum value in the column. Specify the color using a hexadecimal value (e.g., #FF0000 for red).
  • maxColor: The color applied to the maximum value in the column. Specify the color using a hexadecimal value (e.g., #00FF00 for green).
  • applyToBackground: Set this option to true to apply colors to the background of the table cells. Set it to false to apply colors to the text color.
  • columnOptions: An array of ColumnOptions objects that specify the minimum and maximum values for each column in the table. This is useful for cases like pagination where you want to set specific bounds for a column without affecting others. The ColumnOptions interface has the following properties:
    • index: The index of the column (0-based).
    • minValue: The minimum value for this column.
    • maxValue: The maximum value for this column.

You can adjust these options to achieve the desired visual effect for your table columns. For example, you can create a gradient effect from red to green for numeric values in a table.

License

This project is licensed under the MIT License.

Author

Feel free to contribute or report issues on GitHub!