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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@softros/agulhao-charts-node

v1.0.5

Published

Funcoes Node.js para gerar saidas renderizaveis a partir da definicao comum do Agulhao Charts.

Readme

@softros/agulhao-charts-node

Adaptador Node.js do Agulhão Charts.

Ele usa o pacote core para traduzir a definição comum e gera saídas prontas para APIs, relatórios e renderização server-side.

Instalação

npm install @softros/agulhao-charts-node

Gerar HTML

import { gerarHtmlGrafico } from '@softros/agulhao-charts-node'
import type { DefinicaoGrafico } from '@softros/agulhao-charts-core'

const grafico: DefinicaoGrafico = {
    tipo: 'barra',
    titulo: 'Vendas por dia',
    dataset: {
        linhas: [
            { dia: 'Seg', valor: 120 },
            { dia: 'Ter', valor: 200 },
        ],
    },
    mapeamento: {
        eixoX: 'dia',
        eixoY: 'valor',
    },
}

const html = gerarHtmlGrafico(grafico, {
    largura: 800,
    altura: 600,
    tituloDocumento: 'Gráfico de vendas',
})

As opções de gráfico são as mesmas do pacote core, incluindo gauge, cores por série e cores por fatia de pizza.

Exemplo de cor por série:

const grafico: DefinicaoGrafico = {
    tipo: 'linha',
    dataset: {
        linhas: [
            { dia: 'Seg', valor: 150 },
            { dia: 'Ter', valor: 230 },
        ],
    },
    mapeamento: {
        eixoX: 'dia',
        eixoY: 'valor',
    },
    opcoes: {
        serie: {
            nome: 'Vendas',
            cor: [
                { nome: 'Vendas', cor: '#0f766e' },
            ],
        },
    },
}

Exemplo de gauge:

const graficoGauge: DefinicaoGrafico = {
    tipo: 'gauge',
    titulo: 'Meta atingida',
    dataset: {
        linhas: [
            { indicador: 'Conversão', percentual: 72 },
        ],
    },
    mapeamento: {
        rotulo: 'indicador',
        valor: 'percentual',
    },
    opcoes: {
        mostrarLegenda: false,
        serie: {
            nome: 'Performance',
            cor: [
                { nome: 'Performance', cor: '#0f766e' },
            ],
        },
        gauge: {
            minimo: 0,
            maximo: 100,
            mostrarProgresso: true,
        },
    },
}

Mapa padrão do Brasil

Para gráficos tipo: 'mapa' com opcoes.mapa.nome: 'BR', o pacote Node registra automaticamente o GeoJSON padrão dos estados brasileiros fornecido pelo core. Isso permite gerar HTML, SVG e PNG sem buscar o mapa em tempo de execução.

const graficoMapa: DefinicaoGrafico = {
    tipo: 'mapa',
    titulo: 'Indicador por estado',
    dataset: {
        linhas: [
            { estado: 'São Paulo', valor: 46649 },
            { estado: 'Minas Gerais', valor: 21412 },
        ],
    },
    mapeamento: {
        rotulo: 'estado',
        valor: 'valor',
    },
    opcoes: {
        mostrarLegenda: false,
        mapa: {
            nome: 'BR',
            tamanho: '82%',
            centro: {
                x: '43%',
                y: '55%',
            },
        },
    },
}

const imagem = await gerarImagemGraficoPngBase64(graficoMapa)

Gerar SVG em base64

import { gerarImagemGraficoBase64 } from '@softros/agulhao-charts-node'

const imagem = gerarImagemGraficoBase64(grafico, {
    largura: 800,
    altura: 600,
})

console.log(imagem.mimeType) // image/svg+xml
console.log(imagem.base64)
console.log(imagem.dataUri)

Para responder uma API com a imagem:

res.type(imagem.mimeType).send(Buffer.from(imagem.base64, 'base64'))

Gerar PNG em base64

import { gerarImagemGraficoPngBase64 } from '@softros/agulhao-charts-node'

const imagem = await gerarImagemGraficoPngBase64(grafico, {
    largura: 800,
    altura: 600,
})

res.type(imagem.mimeType).send(imagem.buffer)

Também pode retornar via JSON:

res.json({
    imagem: imagem.dataUri,
})

API

gerarHtmlGrafico

function gerarHtmlGrafico(grafico: DefinicaoGrafico, opcoes?: OpcoesHtmlGrafico): string

gerarImagemGraficoBase64

function gerarImagemGraficoBase64(grafico: DefinicaoGrafico, opcoes?: OpcoesImagemGrafico): ImagemGraficoSvgBase64

Retorna SVG em base64.

gerarImagemGraficoPngBase64

function gerarImagemGraficoPngBase64(grafico: DefinicaoGrafico, opcoes?: OpcoesImagemGrafico): Promise<ImagemGraficoPngBase64>

Retorna PNG em base64 e também o Buffer.