Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/openbookpublishers/metrics-widget

Metrics widget that displays book usage statistics
https://github.com/openbookpublishers/metrics-widget

book-metrics hirmeos react

Last synced: about 1 month ago
JSON representation

Metrics widget that displays book usage statistics

Awesome Lists containing this project

README

        

# Metrics Widget

[![Build](https://github.com/OpenBookPublishers/metrics-widget/actions/workflows/build_test_and_check.yml/badge.svg)](https://github.com/OpenBookPublishers/metrics-widget/actions/workflows/build_test_and_check.yml)
[![npm](https://img.shields.io/npm/v/metrics-widget.svg)](https://www.npmjs.com/package/metrics-widget)
![GitHub](https://img.shields.io/github/license/OpenBookPublishers/metrics-widget)

This package is used to display book usage statistics, consuming a [HIRMEOS Metrics API](https://github.com/hirmeos/metrics-api).

![Screenshot of Metrics Widget](https://www.openbookpublishers.com/shopimages/metrics-widget.png)

## Installation

To install via npm:

```bash
npm install --save metrics-widget
```

To install via yarn:

```bash
yarn add metrics-widget
```

To use CDN:

```html

```

## Usage

### React

```javascript
// import the widget
import MetricsWidget from 'metrics-widget';

// ...
const doi = "10.11647/obp.0001";
return (

)
// ...
```

### Vanilla JavaScript

```html


Metrics Widget










let doi = "10.11647/obp.0001";
metricsWidget(document.getElementById('metrics-widget'), doi)

```

## Configuration

Both the react component and the vanilla JS function support the following parameters:

| Parameter | Required | Default | Description |
|-----------------|:--------:|----------------------------------------|-----------------------------------------------------|
| `doi` | required | n/a | The DOI of the work we are displaying data about. |
| `apiEndpoint` | optional | `"https://metrics-api.operas-eu.org/"` | The API to consume. |
| `fullReportUrl` | optional | `null` | Optional URL to a more detailed vie of the metrics. |