Which option is better: installing plotly.js or plotly.js-dist using npm?

When it comes to plotly.js and plotly.js-dist, what exactly sets these two packages apart from each other?

Notably, the installation instructions for plotly.js on npmjs.org specify running 'npm install plotly.js-dist' - why is this necessary?

While plotly.js appears to be a comprehensive project with multiple files, plotly.js-dist is a bundled version consisting of just one file. The reasoning behind this distribution method remains unclear.

Furthermore, it's worth noting that plotly.js-dist is not minified, while a minified file exists within plotly.js, potentially offering an easier way to import the library into projects.

Answer №1

After a thorough check and comparison, it's confirmed that these files are identical.

If you are working with npm + typescript (+Angular), my recommendation is to utilize the option of npm install plotly.js-dist.
If you're using npm (or not) + javascript, the suggestion is to go with option 3 and use plotly.min.js.

Whether the file is minified or not doesn't matter much as every module gets minified after bundling.
Therefore, it ultimately depends on your discretion to choose the file you need to inspect through the developer tool while debugging.

For quick start options, refer to this link.

  1. To install via npm: npm install plotly.js-dist.
  • A readily usable plotly.js distributed bundle.
  • Incorporates trace modules; more details can be found here
  1. Alternatively, utilize the plotly.js CDN hosted by Fastly.
  2. Download the latest release: plotly.js or plotly.min.js. Further information available here.

The choice between them might vary slightly in how you bundle/deploy your project,
and also consider using definition files such as @types/plotly.js
For additional insights, check out the "Bundle information" section in this readme.

Furthermore, if you're working with Angular, here's an additional option: angular-plotly.js.


This serves as my response to your second query regarding "plotly.js" and its complexities in setup for bundling.
My approach and goal have been:

  1. Implementing within angular2-seed alongside Angular 4.
  2. Fully defining each type/interface.

Step 1. Installation of packages.

Modify the command as per @Jesse's suggestion

npm install plotly.js-dist --save
npm install @types/plotly.js --save-dev
npm install @types/d3 --save-dev

Note: @types/d3 is a dependency of @types/plotly.js. If it's unnecessary, remove it from index.d.ts.

Step 2. Renewal of folder to accommodate the definition file.

Rename the folder "plotly.js" to "plotly.js-dist" within "node_modules/@types".

Update - 9/12/2023

This reflects my current environment;

  • Windows 11(x64)
  • Node v18.17.1
  • Angular 13.2.0

My suggested course of action is as follows,

npm i --save plotly.js-dist-min
npm i --save-dev @types/plotly.js-dist-min

This deviates slightly from the official guide.

import { Component, ElementRef, ViewChild, OnInit, AfterViewInit } from '@angular/core';
import * as Plotly from 'plotly.js-dist-min';

@Component({ ... })
export class AppComponent implements OnInit, AfterViewInit {  
  myData!: Partial<Plotly.PlotData>[];
  @ViewChild('chart') div?: ElementRef;

  ngOnInit(): void {
    this.myData = [
      {
        x: ['giraffes', 'orangutans', 'monkeys'],
        y: [20, 14, 23],
        type: 'bar',
      },
    ];
  }

  ngAfterViewInit(): void {
    const element = this.div?.nativeElement;
    Plotly.newPlot(element, this.myData);
  }
}

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Error: Unexpected token : encountered in jQuery ajax call

When creating a web page that requests remote data (json), using jQuery.ajax works well within the same domain. However, if the request is made from a different domain (e.g. localhost), browsers block it and display: No 'Access-Control-Allow-Or ...

The issue arises when TypeScript declarations contain conflicting variables across multiple dependencies

My current project uses .NET Core and ReactJS. Recently, I updated some packages to incorporate a new component in a .tsx file. Specifically, the version of @material-ui/core was updated from "@material-ui/core": "^3.0.3" to "@material-ui/core": "^4.1.3" i ...

Is it true that npm recognizes the latest prerelease versions following semantic versioning rules?

Within my application, users initiate the installation of dependencies by executing npm install, which is a common practice. However, there is one particular package that undergoes frequent changes. In order to avoid ending up with excessively long versio ...

Unable to get jQuery plugin to function properly within a .vue component

I am currently working on a Vue component for my Laravel 5.3 application. I am trying to integrate the Laravel File Manager into a standalone button, but it seems like it's not functioning properly. When I click on the button to choose an image, nothi ...

What is the best way to create a mirrored effect for either a card or text using CSS

Can anyone assist me with this CSS issue? When I hover over to view the movie details, the entire word flips along with it. Is there a way to make only the word flip initially, and then have it return to normal when hovered? The HTML code is included belo ...

Error encountered while using JavaScript for waiting in Selenium

When using selenium and phantomjs to submit a form and then navigate back to the previous page, sometimes I encounter a timeout error as shown below: TimeoutError: Waiting for element to be located By(xpath,//div[@id='ContactFormBody']/div/br) W ...

Node.js encountered an error: Module 'mongoose' not found

C:\Users\Alexa\Desktop\musicapp\Bots\Soul Bot>node bot.js Node.js Error: Missing module 'mongoose' at Function._resolveFilename (module.js:334:11) at Function._load (module.js:279:25) at Module.requir ...

Executing multiple MSSQL queries in a Node.js environment

Currently, I am faced with the challenge of running multiple SQL queries. The issue lies in variables going out of scope due to the asynchronous nature of node.js. I am attempting to find a solution similar to the await keyword available in C#. To clarif ...

Unable to establish a breakpoint in a source-mapped file (illustrated using jQuery)

Having trouble setting a breakpoint on a minified JavaScript source file that is mapped to real sources using a source map file. An example of this problem can be seen on the website jquery.com. On this particular site, the imported script is jquery.min. ...

Updating data scope in AngularJS using $http request not functioning properly

I am facing an issue where the $scope.user_free_status is not updating when I set a user free, but works perfectly fine when I unset the parameter. It's strange that I need to reload the page in one case and not the other. The data fetched is stored i ...

PHP page Not Refreshing Properly Without Ajax

I am in need of assistance. Could someone please provide me with a code that has been thoroughly reviewed and tested for errors to address my issue? The program, 22.php, consists of a form. The desired functionality is for the user to enter information and ...

Executing the script in the package.json file is functional, although it does produce some

After successfully installing ESLint, I can run it in the terminal window with this command: ./node_modules/.bin/eslint app Note: The folder named app is where I want ESLint to inspect. To automate this process, I added the same command to my package.js ...

Web browser local storage

Looking to store the value of an input text box in local storage when a button is submitted <html> <body action="Servlet.do" > <input type="text" name="a"/> <button type="submit"></button> </body> </html> Any sug ...

Utilize MySQL/Javascript to determine percentages

I'm facing a challenge with an SQL query in Entrinsik's Informer. I need to calculate a percentage using JavaScript on the result, but unfortunately, Informer cannot access data down columns (such as the total for the percentage). Therefore, I ha ...

Extracting information from a designated website using Python, including pages with search functionality and javascript features

Visit the website where you will find a search input box in html. Input a company name into the search box, select the first suggestion from the drop-down menu (like "Anglo American plc"), navigate to the URL containing information about that specific com ...

Transforming a string into a JavaScript array using regular expressions

Excuse me if this question has already been asked (this is my first time asking). The content of my string looks like this (after removing the whitespace): "#home #blog description of page here ##article1 ##article2 #contact" When parsed, it will produce ...

What is the method for assigning classes to a Vue.js Functional Component from its parent component?

Imagine a scenario where I have a functional component: <template functional> <div>Some functional component</div> </template> Now, when I render this component within a parent element with classes: <parent> <som ...

Learn the step-by-step process of clicking on a button to modify its properties and deactivate it

I could really use some assistance. I'm trying to make a button: <v-btn dark color="primary" class="square">Tile 1</v-btn> Is there a way I can modify it so that when clicked, it changes to flat, becomes disabled, and switches its color ...

The Ajax PHP function only works on the initial call

The function below calls a PHP file that returns results in JSON format, which are assigned to JavaScript values. The PHP function has been thoroughly tested and works as expected. The results are stored in variables until the market variable is changed wi ...

Submitting form data using Vue and PHPMailer

I've been encountering an issue with submitting a contact form from a page. After submitting the form, nothing seems to happen. My tech stack includes Vue, Axios, and PHPMailer for handling this functionality. Upon inspecting the network tab, it appea ...