Laravel undefined uPlot library

I’m trying to use the library uPlot into my view. But I’m getting an error of Uncaught ReferenceError: uPlot is not defined it seems that it can’t find the uPlot library but this library is already loaded in the bootstrap as shown below

// resources/js/bootstrap.js

window._ = require('lodash');
try {
window.Popper = require('popper.js').default;
window.$ = window.jQuery = require('jquery');

require('bootstrap');
require('admin-lte');

require('../../node_modules/uplot/dist/uPlot.iife.min');

} catch (e) {}

Now the chart.js is loaded in the resource/js/app.js as shown below

require('./bootstrap');
require('./chart');

Now in my chart.js I have this

$(function () {

function getSize(elementId) {
return {
width: document.getElementById(elementId).offsetWidth,
height: document.getElementById(elementId).offsetHeight,
}
}

let data = [
[0, 1, 2, 3, 4, 5, 6],
[28, 48, 40, 19, 86, 27, 90],
[65, 59, 80, 81, 56, 55, 40]
];

const optsLineChart = {
... getSize('lineChart'),
scales: {
x: {
time: false,
},
y: {
range: [0, 100],
},
},
series: [
{},
{
fill: 'transparent',
width: 5,
stroke: 'rgba(60,141,188,1)',
},
{
stroke: '#c1c7d1',
width: 5,
fill: 'transparent',
},
],
};

let lineChart = new uPlot(optsLineChart, data, document.getElementById('lineChart'));
window.addEventListener("resize", e => {
lineChart.setSize(getSize('lineChart'));
});
});

Now the element lineChart is already defined but it’s throwing an error when the script reaches the line new uPlot. I checked the pub/js/app.js and the uPlot was successfully imported. As well as the chart.js is included in the app.js. But one this I noticed is the script of chart.js is added at the very top of the app.js file while the uPlot is added at the bottom part.

How can I fix this? It doesn’t seem like the uPlot library is being read or loaded in the chart.js file

from Newest questions tagged laravel-5 – Stack Overflow https://ift.tt/3jUGG7H
via IFTTT

Related Posts

Codeigniter : Parse error: syntax error, unexpected ‘const’ (T_CONST), expecting variable (T_VARIABLE) in Laravel project

I’m getting following error: **Parse error: syntax error, unexpected ‘const’ (T_CONST), expecting variable (T_VARIABLE)** Note : It’s working in local but facing issue in production server. private…

Firebase receive notification while tab is active or on focus

What i want is to be able to perform an action when a user receives a notification while the browser is open and tab is active or…

Laravel’s alias loader does not find class

We have a legacy project that we cannot update and we need to make some changes in symfony’s Response.php in vendor. We have solved this by copying…

Laravel 5 – generic document management

I have a system where you can create different types of unique documents. For instance, one document is called Project Identified and this expects certain inputs. Originally,…

Laravel Nova limit the results in indexQuery

I ran intro a situation where I need to limit the results of a resource to only 3 results. To be more specific, based on the logged…

Auditoria en laravel 5.8 [closed]

Cómo puedo automatizar el registro de actividades de un usuario en laravel? Si un usuario ingresa a un app de laravel, debo guardar toda su actividas, a…

Leave a Reply

Your email address will not be published.