Socket
Book a DemoInstallSign in
Socket

@cloudflare/chart-color-legend

Package Overview
Dependencies
Maintainers
40
Versions
519
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

6.0.2
latest
npmnpm
Version published
Weekly downloads
1K
15.23%
Maintainers
40
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 22 May 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

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.