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

@geins/ralph-module-chart-js

v1.0.1

Published

Chart.js module for Geins PWA Storefront Ralph

Downloads

3

Readme

NPM Package NPM Downloads Geins

Start Geins Free Trial Geins Docs

geins repo banner

Chart.js module for Geins PWA Storefront Ralph

A module for Geins PWA Storefront Ralph that adds Chart.js charts to your storefront.

Pre-requisites

Description

This module enables you to add Chart.js charts to your storefront in seconds.

Module can be used in any page of your storefront and is configuerd to work with Geins Cart out-of-box. Module can be added via Geins CMS or any CMS of your choice.

Installation

1. Install the module

npm i @geins/ralph-module-chart-js

2. Add the module to your Geins PWA Storefront Ralph

Add the module to your Geins PWA Storefront Ralph by adding the following line to your nuxt.config.js file:

// nuxt.config.js
...
  modules: [
    [
        '@geins/ralph-module-chart-js',
        {
            enabled: true,
            debug: true
        }
    ]
  ],

To use with Geins CMS (no-code)

1. Add the module to your Geins PWA Storefront Ralph

Use the @geins/ralph-module-cms-json-container

npm i @geins/ralph-module-cms-json-container

2. Add the module to your Geins PWA Storefront Ralph

Add module to your nuxt.config.json file:

...
    modules: [
      '@geins/ralph-module-cms-json-container'
    ]
..

Set the widgetRenderTypesComponents in your nuxt.config.json file to use the GeinsWidgetJsonContainer component for the JSON widget type.

// nuxt.config.js
...
  publicRuntimeConfig: {
      widgetRenderTypesComponents: {
        JSON: 'GeinsWidgetJsonContainer'
      },
  }
...

Module Options

Add extra options to module configuration in nuxt.config.js file. | Parameter | Type | Default | Example | |-|-|-| | enabled | String | true | Enables the module| | debug | String | false | Enables debug info to console | | chartOptions | Object | {} | For chart-customization, add your own options object here Chart.js docs | | chartPlugins | Array | [] | If available, add an arrray of your chart-plugins here Chart.js docs |

Usage

Add component to desired page of your storefront. Either by cms or as a component.

Component

Components

Module adds two components to your storefront. GeinsChartJs and GeinsWidgetChartJs.

GeinsChartJs

This component is used to show the streamify player. It is used by the GeinsWidgetChartJs component. You can use it directly in your page if you want to add the player directly to your page.

Properties

The properties of the component are one to one with the Chart.js API. You can add any property to the component and it will be passed to the API.

| Property | Type | Default Value | Required | Description | | --------------- | ------- | ------------- | -------- | -------------------------------------------------------------------------------------------------- | | type | String | 'line' | No | Type of chart | | data | Object | - | Yes | Dataset and labels for your chart | | options | Object | default Chart.js options | No | Chart options | | plugins | Array | [] | No | Chart plugins|

Use with Geins CMS

Add a JSON Widget to your page in the Geins CMS. Add the following JSON to your widget (replace with your own dataset and labels). Customize the values according to your own dataset and preferences.

Example of JSON widget content:

{
  "renderWidget": "GeinsWidgetChartJs",
  "data": {
    "data": {
        "labels": ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"],
        "datasets": [{
            "label": "Sunlight hours per month",
            "data": [197, 216, 232, 244, 248, 290, 288, 274, 268, 246, 212, 182]
        }]
    }
  }
}

Customizing Styling of chart to match your storefront

To add global customization to your charts, create a folder inside your static-folder called chartJs. Inside this create a file called chartOptions.js. Inside this file, add your custom options (see below example):

// chartOptions.js

export const chartOptions = {
    responsive: true,
    maintainAspectRatio: false,
    scales: {
      y: {
        border: {
          display: false
        },
        grid: {
          display: false,
          drawTicks: false
        }
      },
      x: {
        border: {
          display: false
        },
        grid: {
          display: false,
          drawTicks: false
        }
      }
    }
}

See docs for Chart.js options for more options.

Import your chartOptions.js file into your nuxt.config.js:

import { chartOptions } from './static/chartJs/chartOptions';

Add the chartOptions to your module options:

      [
        '@geins/ralph-module-chart-js',
        {
          enabled: true,
          chartOptions: chartOptions,
        }
      ]

As a component or with any CMS

Add the component to your page. Add the type as properties to the component.

<GeinsChartJs 
    :type="chartType"
    :data="chartData"
    :options="chartOptions"
    :plugins="chartPlugins"
/>

Tips!

Add a chart to you PDP to display product meta data in a intuitive way.