Socket
Book a DemoInstallSign in
Socket

@cloudflare/chart-color-legend

Package Overview
Dependencies
Maintainers
43
Versions
520
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@cloudflare/chart-color-legend

Cloudflare color legend presentational component

latest
npmnpm
Version
6.0.3
Version published
Weekly downloads
861
-14.41%
Maintainers
43
Weekly downloads
 
Created
Source

@cloudflare/chart-color-legend

Cloudflare color legend presentational component

Installation

Installation with yarn is recommended


$ yarn add @cloudflare/chart-color-legend

Usage

import React from 'react';
import { Box } from '@cloudflare/component-box';
import {
  SingleColorLegend,
  ContinuousColorLegend,
  SeriesToggleLegend
} from '../../src';

class ViewComponent extends React.Component {
  state = {
    disabledSeries: []
  };

  render() {
    return (
      <div>
        <div>Series Toggles:</div>
        <SeriesToggleLegend
          series={[
            {
              name: 'dog',
              color: 'red',
              enabled: this.state.disabledSeries.indexOf('dog') === -1
            },
            {
              name: 'cat',
              color: 'green',
              enabled: this.state.disabledSeries.indexOf('cat') === -1
            },
            {
              name: 'pig',
              color: 'blue',
              enabled: this.state.disabledSeries.indexOf('pig') === -1
            }
          ]}
          onToggle={disabledSeries => this.setState({ disabledSeries })}
        />
        <div>Single Colors:</div>
        <Box display="flex">
          <Box margin="5px">
            <SingleColorLegend label="Cat" color="lightblue" />
          </Box>
          <Box margin="5px">
            <SingleColorLegend label="Dog" color="brown" highlight={true} />
          </Box>
        </Box>
        <div>Continuous Color Scale:</div>
        <ContinuousColorLegend
          minVal={0}
          maxVal={12345}
          highlightVal={5678}
          valueFormatter={n => `${Math.round(n / 1e2) / 10}k`}
          colors={['green', 'yellow', 'red']}
          label="Units"
          colorScaleExp={1 / 2}
          enableAxis={true}
        />
      </div>
    );
  }
}

export default ViewComponent;

FAQs

Package last updated on 10 Sep 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts