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

luna_charts

v1.0.9

Published

LUNA Charts is an acronym and stands for Library for Userfriendly 'N Accessible Charts. It is a component library for creating accessible charts.

Downloads

3

Readme

LUNA Charts

Table of contents

Description

Luna was my family dog. LUNA Charts is an acronym and stands for Library for Userfriendly 'N Accessible Charts. It is a component library for creating accessible charts. The package has three built-in charts:

  • LineChart
  • BarChart
  • PieChart

Important: The package is still in process

How to install

npm i luna_charts

How to use

For example pie chart:

import PieChart from 'luna_charts/src/components/PieChart.svelte';
import type { PieSeries, PieSlice } from 'luna_charts/types/series/PieSeries.Type';
import type {ChartInfo} from 'luna_charts/types/attributes/ChartInfo.types';

export let chartInfo: ChartInfo = {
  title: "A typical Pie chart",
  desc: "This is a accessible description. Your screenreader will read it for you.",
  source: "https://www.w3.org"
} as ChartInfo

const pieSlices: PieSlice[] = [
  {
    name: 'Firefox',
    percent: 0.35,
    color: 'ff0000',
  },
  {
    name: 'Chrome',
    percent: 0.35,
    color: 'ffff00',
  },
  {
    name: 'Safari',
    percent: 0.2,
    color: 'ffffff',
  },
  {
    name: 'IE',
    percent: 0.1,
    color: '000000',
  },
];

export const testPieSeries: PieSeries = {
  slices: pieSlices,
};

<PieChart chartInfo="{chartInfo}" series="{testPieSeries}" \>

How to edit a chart

LUNA Charts offers you some ready-made data types for editing charts.

// defines the description, title and source
import type {ChartInfo} from '../types/attributes/ChartInfo.types';

export let chartInfo: ChartInfo = {
  title: "Revenue of three big companies",
  desc: "The bar chart shows the revenue for Apple, Google and Microsoft divided in the seasons.",
  source: "https://www.w3.org"
} as ChartInfo

If you want to change the labels for the axis, then you can use the data type Labels. Note: The pie chart hat no labels attribut. Example:

// defines the different labels for the axis
import {type Labels} from '../types/attributes/Labels.type';

export let labels: Labels = {x: "Seasons", y: "Euro in million", secondY: ''} as Labels;

You are not good at math? Don´t worry! With Series, LUNA will render for you every number. You need only to choose the right data type: If you want to change the labels for the axis, then you can use the data type Labels. Note: The pie chart hat no labels attribut. Example:

// Prepare the series for the BarChart
import type { BarSeries, BarValues, Bar } from '../types/series/BarSeries.type';

const appleBarValues: BarValues[] = [
  {
    value: 10,
    ariaLabel: 'The revenue in 2020 for Apple is: ',
  },
  {
    value: 20,
    ariaLabel: 'The revenue in 2021 for Apple is: ',
  },
];

const appleRevenue: Bar = {
  name: 'Apple',
  barValues: appleBarValues,
};

export const testBarSeries: BarSeries = {
  series: [appleRevenue],
  category: ['2020', '2021'],
};

Set width and height with dimension:

import type {Dimension} from '../types/attributes/Dimension.type';

export let dimension: Dimension = {width: "800", height: "300"} as Dimension;

Do you need more contrast? Then do this:

<LineChart hatchPatterns="true" />

Use themes

Ok, that sound good! But how i can change the color or other stuff of the chart? Also here LUNA provides suitable data types:

import { HATCH_PATTERNS } from '../types/theme/Hatch.type.ts';
import { CONTRAST_COLORS } from '../types/theme/Theme.type.ts';
import type { BarTheme } from '../types/theme/Theme.type';

export const defaultBarTheme: BarTheme = {
  name: 'barDefaultTheme',
  colors: CONTRAST_COLORS,
  focusColor: '#66ff99',
  wrapperStyles: {
    backgroundColor: '#F7F7F7',
  },
  grid: {
    gridColor: '',
    gridSize: '',
  },
  hatches: [HATCH_PATTERNS.CIRCLES, HATCH_PATTERNS.DIAGONAL, HATCH_PATTERNS.H_LINE],
};

Please note, every chart has it own theme.

Doc

We document our charts in Storybook. For more detailed information run:

npm run storybook

Examples

You want to see, how the charts look likes? Click here

Known problems

If you install the package in a svelte project, add the following line in your tsconfig.json:

{
  "extends": "@tsconfig/svelte/tsconfig.json",

  "include": ["src/**/*","node_modules/luna_charts/src/**/*"],
  "exclude": ["__sapper__/*", "public/*"]
}

Svelte need to compile the charts in the luna_package package too.