Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@geins/ralph-module-chart-js

Package Overview
Dependencies
Maintainers
2
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@geins/ralph-module-chart-js

Chart.js module for Geins PWA Storefront Ralph

  • 1.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
2
Weekly downloads
 
Created
Source

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.

PropertyTypeDefault ValueRequiredDescription
typeString'line'NoType of chart
dataObject-YesDataset and labels for your chart
optionsObjectdefault Chart.js optionsNoChart options
pluginsArray[]NoChart 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.

Keywords

FAQs

Package last updated on 07 Jul 2023

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

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc