I'm getting this error on yarn serve:
WAIT Compiling... 11:14:16 AM
98% after emitting
ERROR Failed to compile with 1 error 11:15:03 AM
error
Converting circular structure to JSON
--> starting at object with constructor 'NormalModule'
| property 'dependencies' -> object with constructor 'Array'
| index 0 -> object with constructor 'HarmonyCompatibilityDependency'
--- property 'originModule' closes the circle
(this error happens while yarn is still open - not a full crash)
Or somethimes yarn crashes entirely with :
90% additional chunk assets processing HotModuleReplacementPluginC:\PATH\TO\MY\PROJECT\client\node_modules\webpack\lib\ModuleTemplate.js:85
throw e;
^
TypeError: C:\PATH\TO\MY\PROJECT\client\node_modules\cache-loader\dist\cjs.js??ref--13-0!C:\PATH\TO\MY\PROJECT\client\node_modules\babel-loader\lib\index.js!C:\PATH\TO\MY\PROJECT\client\node_modules\eslint-loader\index.js??ref--14-0!C:\PATH\TO\MY\PROJECT\client\src\js\routes\models\virtuals\index.js
Converting circular structure to JSON
--> starting at object with constructor 'NormalModule'
| property 'dependencies' -> object with constructor 'Array'
| index 0 -> object with constructor 'HarmonyCompatibilityDependency'
--- property 'originModule' closes the circle
at JSON.stringify (<anonymous>)
at requireChunkId (C:\PATH\TO\MY\PROJECT\client\node_modules\webpack\lib\RuntimeTemplate.js:320:35)
at Array.map (<anonymous>)
at RuntimeTemplate.blockPromise (C:\PATH\TO\MY\PROJECT\client\node_modules\webpack\lib\RuntimeTemplate.js:322:6)
at RuntimeTemplate.moduleNamespacePromise (C:\PATH\TO\MY\PROJECT\client\node_modules\webpack\lib\RuntimeTemplate.js:136:24)
at ImportDependencyTemplate.apply (C:\PATH\TO\MY\PROJECT\client\node_modules\webpack\lib\dependencies\ImportDependency.js:22:27)
at JavascriptGenerator.sourceDependency (C:\PATH\TO\MY\PROJECT\client\node_modules\webpack\lib\JavascriptGenerator.js:151:12)
at JavascriptGenerator.sourceBlock (C:\PATH\TO\MY\PROJECT\client\node_modules\webpack\lib\JavascriptGenerator.js:44:9)
at JavascriptGenerator.sourceBlock (C:\PATH\TO\MY\PROJECT\client\node_modules\webpack\lib\JavascriptGenerator.js:133:9)
at JavascriptGenerator.generate (C:\PATH\TO\MY\PROJECT\client\node_modules\webpack\lib\JavascriptGenerator.js:23:8)
at NormalModule.source (C:\PATH\TO\MY\PROJECT\client\node_modules\webpack\lib\NormalModule.js:522:33)
at ModuleTemplate.render (C:\PATH\TO\MY\PROJECT\client\node_modules\webpack\lib\ModuleTemplate.js:54:32)
at C:\PATH\TO\MY\PROJECT\client\node_modules\webpack\lib\Template.js:233:28
at Array.map (<anonymous>)
at Function.renderChunkModules (C:\PATH\TO\MY\PROJECT\client\node_modules\webpack\lib\Template.js:230:30)
at HotUpdateChunkTemplate.render (C:\PATH\TO\MY\PROJECT\client\node_modules\webpack\lib\HotUpdateChunkTemplate.js:48:34)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
Context
I have one web application, SPA(laravel-enso), Laravel + VueJs.
In GIT in the develop branch, we do not have apexcharts installed and integrated. Another branch called upgrade has apexcharts installed:
client/package.json
"serve": "vue-cli-service serve --port 8082 --mode development",
"build": "vue-cli-service build --no-clean",
...
"dependencies": {
"apexcharts": "^3.35.0",
...
"vue3-apexcharts": "^1.4.1",
}
...
In the upgrade branch I have one vue component called RrdGraph that makes use of apexcharts :
import VueApexCharts from "vue3-apexcharts";
export default {
name: 'RrdGraph',
components: {
apexchart: VueApexCharts,
},
...
connectionSeries: [
{
name: "Current",
data: [],
},
{
name: "Total",
data: [],
},
{
name: "Request",
data: [],
},
],
connectionChartOptions: {
chart: {
id: 'connectionChart',
group: 'network',
width: 800,
background: '#fff',
// zoom: {
// autoScaleYaxis: false, //not supported on multi-axis
// },
animations: {
enabled: false,
},
stacked: false,
},
dataLabels: {
enabled: false,
},
plotOptions: {
bar: {
columnWidth: '30%',
rangeBarOverlap: false,
},
},
markers: {
size: 0,
style: 'hollow',
colors: [
'#00af00', //Current / 0
'#0022ff', //New (Total) / 1
'#000000', //Request / 4
],
},
stroke: {
width: [3, 3, 2],
colors: [
'#00af00', //Current / 0
'#0022ff', //New (Total) / 1
'#000000', //Request / 4
],
// lineCap: 'square',
curve: 'straight', //'smooth', 'straight', 'stepline'
},
fill: {
opacity: 1,
},
xaxis: {
type: 'datetime',
min: new Date(Date.now()).getTime() - 31536000, //1 year
tickAmount: 10,
},
yaxis:
[
{
seriesName: 'Current',
showAlways: true,
axisTicks: {
show: true,
},
axisBorder: {
show: true,
color: '#0000FF',
},
labels: {
show: true,
style: {
colors: '#0000FF',
},
},
markers: {
colors: '#0000FF',
},
title: {
text: "Current & Total",
style: {
color: '#0000FF',
},
},
type: 'numeric',
decimalsInFloat: 1,
tickAmount: 10,
},
{
seriesName: 'Current',
showAlways: true,
axisTicks: {
show: false,
},
axisBorder: {
show: false,
},
labels: {
show: false,
},
type: 'numeric',
decimalsInFloat: 1,
tickAmount: 10,
},
{
seriesName: 'Request',
showAlways: true,
opposite: false,
axisTicks: {
show: true,
},
axisBorder: {
show: true,
color: '#000000',
},
labels: {
show: true,
style: {
colors: '#000000',
},
},
title: {
text: "Request (per 5 min)",
style: {
color: '#000000',
},
},
type: 'numeric',
decimalsInFloat: 1,
tickAmount: 10,
},
],
tooltip: {
x: {
format: 'dd MMM yyyy HH:mm:ss',
},
// followCursor: true,
// fixed: {
// enabled: true,
// position: 'topRight',
// offsetX: 5,
// offsetY: 25,
// },
},
legend: {
horizontalAlign: 'center',
fontSize: '12px',
offsetX: -100,
offsetY: 5,
},
colors: [
'#00af00', //Current / 0
'#0022ff', //Total / 1
'#000000', //Request / 4
],
},
Initially I looked at this error as a very generic one, and I looked into package.json dependencies and devDependencies and if there are circular references. But I saw no issues with the dependencies of either apexcharts or vue3-apexcharts.
I've also observer that yarn build was working and only yarn serve was not. Looking deeper into what build and serve were doing, I saw that the --mode development was generating the error - since if I added --mode development to yarn build params it was crashing.
One important fact, that made me think this is related to apexcharts was that on the develop branch (the one that did not have apexcharts installed) yarn serve was not generating this error. And these 3 things were the only differences (RrdGraph compoenent and the 2 dependencies, apexcharts and vue3-apexcharts)
I started a long process of divide and conquer by removing bits and pieces from my RrdGraph component that used apexcharts.
I removed and removed, each time checking what part of the code was generating the error, and which removed part was not generating the error.
I reached this part:
plotOptions: {
bar: {
horizontal: false,
borderRadius: 0,
columnWidth: '30%',
// barHeight: '50%',
distributed: false,
rangeBarOverlap: false,
rangeBarGroupRows: false,
},
},
If I removed this part. Yarn was working again, no errors!
I tried to associated this with something and thought that if I remove the lines with bar options that are default values anyways, it is working - like this:
plotOptions: {
bar: {
columnWidth: '30%',
rangeBarOverlap: false,
},
},
(these being the only actual changes that we wanted that are not default values)
I thought that was it, since it was working again.
But then, the next one hit me harder:
We changed some comments in these options, so instead of //Total / 1 we changed it to //New (Total) / 1:
markers: {
size: 0,
style: 'hollow',
colors: [
'#00af00', //Current / 0
'#0022ff', //New (Total) / 1
'#000000', //Request / 4
],
},
stroke: {
width: [3, 3, 2],
colors: [
'#00af00', //Current / 0
'#0022ff', //New (Total) / 1
'#000000', //Request / 4
],
This made yarn serve crash again :(
Interestingly, it was only the first comment within markers, not the one within stroke that made it crash.
Conclusions:
I have no idea what is happening and why it behaves like this.
It might be also something related to webpack and what it converts these options to JSON.
It might be something related to how the options are passed to the component or, how this is converted to JSON in the --mode development, but something is strange
I'm wondering if someone had this issue or could share some hints.
Related
I'm trying to make an area chart using apexcharts with nuxt (vue2), but the area is not getting filled, and the options i set in chartOptions for fill are getting used by the line itself instead of the area, as below:
this is my apexchart component:
<client-only>
<apexcharts
type="area"
width="70%"
ref="realtimeChart"
:options="chartOptions"
:series="series">
</apexcharts>
</client-only>
this is my chartOptions:
chartOptions: {
chart: {
toolbar: {
show: true,
tools: {
download: true,
selection: false,
zoom: true,
zoomin: false,
zoomout: false,
pan: false,
reset: false,
},
},
id: "basic-bar",
colors: ["#FFA07A"],
fill: {
type: "gradient",
gradient: {
shadeIntensity: 1,
opacityFrom: 0.7,
opacityTo: 0.9,
stops: [0, 100],
},
},
forecastDataPoints: {
count: 28,
strokeWidth: 4,
dashArray: 5,
},
title: {
text: "doesnt matter",
align: "center",
},
grid: {
borderColor: "#e7e7e7",
row: {
colors: ["#f3f3f3", "transparent"],
opacity: 0.5,
},
},
xaxis: {
type: "date",
tickAmount: 40,
},
yaxis: [
{
title: {
text: "Mt CO2eq/we",
},
forceNiceScale: true,
},
]
},
Can anyone help ?
I was declaring type: "line" in my series. thats all.
I want to put time data in x-axis labels in vue chart.js . There is a way in pure js code, not vue, but I can't find it in vue version.
Below is my code.
export default {
name: "LineChart",
components: {
LineChartGenerator,
},
props: {
chartId: {
type: String,
default: "line-chart",
},
datasetIdKey: {
type: String,
default: "label",
},
width: {
type: Number,
default: 100,
},
height: {
type: Number,
default: 280,
},
cssClasses: {
default: "",
type: String,
},
styles: {
type: Object,
default: () => {},
},
plugins: {
type: Array,
default: () => [],
},
},
data() {
return {
chartData: {
labels: "???",
datasets: [
{
label: "vacuum",
backgroundColor: "#534e7f",
data: this.$store.state.cnc1,
},
],
},
chartOptions: {
maintainAspectRatio: false,
},
};
},
};
I tried a lot of things similar to the one below but failed.
I also installed the extension but it failed.
scales: {
x: {
type: "time",
time: {
unit: "day",
},
},
},
I want to make something like this.
Most of the vue examples don't help by putting specific values in 'labels:' beforehand.
How can I get the value of the label in real time?
I tried putting time data into the store, but only the time when execution started is displayed.
Or like this...My head is a potato.Any help would be appreciated.
did you match label and data like this?
chartData: {
labels: [ 'January', 'February', 'March'],
datasets: [
{
label: 'Data One',
backgroundColor: '#f87979',
data: [40, 20, 12]
}
]
},
I have the following Chart Component:
<template>
<div class="gauge-chart">
<chart :options="options"></chart>
</div>
</template>
<script>
export default {
props: {
chartValue: { type: Number, required: true },
chartName: { type: String, required: true },
},
data: () => ({
options: {
series: [
{
type: "gauge",
startAngle: 180,
endAngle: 0,
min: 1,
max: 5,
splitNumber: 8,
axisLine: {
lineStyle: {
width: 6,
color: [
[0.25, "#7CFFB2"],
[0.5, "#58D9F9"],
[0.75, "#FDDD60"],
[1, "#FF6E76"],
],
},
},
pointer: {
icon: "arrow",
offsetCenter: [0, "-30%"],
itemStyle: {
color: "auto",
},
},
axisTick: {
length: 12,
lineStyle: {
color: "auto",
width: 1,
},
},
splitLine: {
length: 20,
lineStyle: {
color: "auto",
width: 5,
},
},
title: {
fontSize: 30,
},
data: [
{
value: this.chartValue,
name: this.chartName,
},
],
},
],
},
}),
};
</script>
As you can see I am tryng to inject chartValue and chartName props into options.series.data.value and options.series.data.name respectively.
The values for the properties are coming from
<GaugeChart chartName="Sleep" :chartValue="2" />
At the moment the values are hardcoded, but eventually they will be dynamic.
However it keep throwing the following error:
"TypeError: Cannot read property 'chartName' of undefined"
"TypeError: Cannot read property 'chartValue' of undefined"
I have done a colsole.log of both properties and they come up as "Sleep" and 2. I have also done a typeof on both property names and they both come up as String and Number, respectively.
Could somebody tell me where I am going wrong please?
Many thanks in advance.
You cannot use 'this' operator inside an arrow function so define your data section as a normal function
<script>
export default {
props: {
chartValue: { type: Number, required: true },
chartName: { type: String, required: true },
},
data() {
return {
options: {
series: [
{
type: "gauge",
startAngle: 180,
endAngle: 0,
min: 1,
max: 5,
splitNumber: 8,
axisLine: {
lineStyle: {
width: 6,
color: [
[0.25, "#7CFFB2"],
[0.5, "#58D9F9"],
[0.75, "#FDDD60"],
[1, "#FF6E76"],
],
},
},
pointer: {
icon: "arrow",
offsetCenter: [0, "-30%"],
itemStyle: {
color: "auto",
},
},
axisTick: {
length: 12,
lineStyle: {
color: "auto",
width: 1,
},
},
splitLine: {
length: 20,
lineStyle: {
color: "auto",
width: 5,
},
},
title: {
fontSize: 30,
},
data: [
{
value: this.chartValue,
name: this.chartName,
},
],
},
],
},
};
}
};
</script>
You should use the prop in following manner:
<GaugeChart chart-name="Sleep" chart-value="2" />
Documentation
HTML attribute names are case-insensitive, so browsers will interpret any uppercase characters as lowercase.
I had created a project using vuejs+Vue-CLI and integrated echarts in it. Echarts are working well in all browsers but when I open it in IE-11 version, page can't load and it shows following error:
[object Error]{description: "Expected ')'", message: "Expected ')'", name: "SyntaxError", number: -2146827282, stack: "SyntaxError...", Symbol()_n.kyufm4c0tec: undefined, Symbol()_p.kyufm4c0tec: undefined, Symbol()_q.kyufm4c0tec: undefined, Symbol()_r.kyufm4c0tec: undefined, Symbol(Lang fallback)_m.kyufm4c0tec: undefined, Symbol(util.promisify.custom)_o.kyufm4c0tec: undefined}
Here is my code:
<template>
<ECharts :options="pie" style="width:300px; height:260px">
</ECharts>
</template>
<script>
import ECharts from "vue-echarts/components/ECharts.vue";
import "echarts/lib/chart/pie";
import "echarts/lib/component/title";
export default {
components: {
ECharts
},
data() {
return {
pie: {
backgroundColor: "transparent",
tooltip: {
trigger: "item",
formatter: "{a} <br/>{b} : {c} ({d}%)"
},
series: [{
name: "Product Sales",
type: "pie",
radius: ["50%", "70%"],
avoidLabelOverlap: false,
data: [{
value: 1,
name: "Product A"
},
{
value: 2,
name: "Product B"
},
{
value: 3,
name: "Product C"
}
],
label: {
normal: {
show: false,
position: "center"
},
emphasis: {
show: true,
textStyle: {
fontSize: "20",
fontWeight: "bold"
}
}
},
labelLine: {
normal: {
show: false
}
}
}]
}
};
}
};
</script>
what's an issue in IE browser I also searched for the solution and tried it but did't get the result.
Versions:
echarts-4.1.0,
vue-echarts: 3.1.1
Any help will be appreciated! Thanks
The documentation of vue-echarts-v3 does not inform it, but you have to add the echarts on your webpack (or any other bundler you are using) configuration as well.
{
test: /\.js$/,
loader: 'babel-loader',
include: [
resolve('src'),
resolve('test'),
resolve('node_modules/vue-echarts-v3/src'), // Their suggestion https://www.npmjs.com/package/vue-echarts-v3
resolve('node_modules/echarts/lib'), // Not suggested, but required as well
]
},
While using the chart.js and the plugin chartjs-plugin-annotation, annotations are not showing while using angular 5, no error messages are displayed.
I have created a cut down example of code that exhibits the problem
console.log(Chart.plugins) shows the plugin looks to be registered as plugin[3] however it doesn't have an id as the inbuilt ones do, is this a problem?
chart.component.ts
import { Component, Inject } from '#angular/core';
import { Chart } from 'chart.js';
import 'chartjs-plugin-annotation';
#Component({
selector: 'app-chart-component',
templateUrl: './chart.component.html'
})
export class ChartComponent {
public currentCount = 0;
chart : Chart ; // This will hold our chart info
simpleChart() {
console.log(Chart.plugins);
this.chart = new Chart('canvas', {
type: 'line',
data: {
labels: ['0','1','2', '3','4'],
datasets: [
{
data: [0,1,2,5,4,5],
borderColor: "#3cba9f",
fill: false,
},
]
},
options: {
legend: {
display: false
},
scales: {
xAxes: [{
display: true
}],
yAxes: [{
display: true,
id: 'y-axis-0'
},
]
},
plugins: {
annotation: {
annotations: [{
type: 'line',
id: 'hLine',
mode: 'horizontal',
scaleID: 'y-axis-0',
value: 2.5, // data-value at which the line is drawn
borderWidth: 2.5,
borderColor: 'black'
}]
}
}
}
});
}
ngOnInit() {
this.simpleChart();
}
}
Any assistance would be greatly appreciated.
I had some fun trying to get annotations working - in case you haven't already solved it, try this...
Change your imports statement to:
import * as ChartAnnotation from 'chartjs-plugin-annotation';
Change ngOnInit() to:
ngOnInit() {
let namedChartAnnotation = ChartAnnotation;
namedChartAnnotation["id"]="annotation";
Chart.pluginService.register( namedChartAnnotation);
this.simpleChart();
}
Lastly, I believe the annotation object is supposed to be a child of options, not plugins. Mine looks like this:
"options": {
"legend": {
"display": true
},
"scales": {
"xAxes": [{
"display": true
}
],
"yAxes": [{
"display": true,
"ticks": {
"min": 0,
"max": 40
}
}
]
},
"tooltips": {
"enabled": true,
"backgroundColor": "#eee",
"titleFontColor": "#000"
},
"annotation": {
"annotations": [{
"type": "box",
"xScaleID": "x-axis-0",
"yScaleID": "y-axis-0",
"yMin": 0,
"yMax": 15,
"xMin": 864,
"xMax": 1285,
"borderWidth": 1,
"backgroundColor": "rgba(200,60,60,0.25)",
"borderColor": "rgba(200,60,60,0.25)"
}, {
"type": "box",
"xScaleID": "x-axis-0",
"yScaleID": "y-axis-0",
"yMin": 30,
"yMax": 40,
"xMin": 864,
"xMax": 1285,
"borderWidth": 1,
"backgroundColor": "rgba(60,60,200,0.25)",
"borderColor": "rgba(60,60,200,0.25)"
}
]
}
}
Makes for a pretty graph :)
(except I got the colours bass ackwards! Oops!)
As an adition of what Ade said. You can also add the plugin this way
import { ChartOptions } from 'chart.js';
import * as ChartAnnotation from 'chartjs-plugin-annotation';
this.chart = new Chart('canvas', {
...
options: {
...
annotation: { ... }
} as ChartOptions,
plugins: [ChartAnnotation]
});
Adding the {...} as ChartOptions makes that TypeScript doesn't complain
To anyone having a TypeScript error saying that annotation isn't a ChartOptions property. After looking for an answer for a week or two I found a way to fix the issue.
Follow this path: node_modules/#types/chart.js/index.d.ts
Open index.d.ts, locate interface ChartOptions {
and add this line.
annotation?: Object;
}
This is how I fixed my issue after every other solution failed.
I have the same problem recently, I fixed it by registerPlugin under constructor.
Here is my solution:
import the plugin to your component:
import * as annotations from 'chartjs-plugin-annotation';
add this line to your constructor:
constructor(...) { BaseChartDirective.registerPlugin(annotations);}
If you are using typescript you may need to extend the ChartOptions interface with annotation:
interface CustomizeChartOptions extends ChartOptions {
annotation?: any
}
config your chartOptions with annotation
public barChartOptions: CustomizeChartOptions = {
// your other ChartOptions setting here
annotation: {
annotations: [
{
drawTime: "afterDatasetsDraw",
type: 'line',
mode: 'vertical',
scaleID: 'x-axis-0',
value: '1 Dec',
borderColor: 'red',
borderWidth: 2,
label: {
content: 'CURRENT',
enabled: true,
position: 'top'
}
}
]
}
};
I know I am late, but, as of now (ng2-charts 3.0.11), these answers are not working as the API changed. The annotation configuration must now be in plug-ins.
The annotation plug-in must be registered before being used.
Here is what i found, from the examples:
in app.module.ts:
import { NgChartsModule } from 'ng2-charts';
import { default as Annotation } from 'chartjs-plugin-annotation'
// ...
imports: [
//...
NgChartsModule.forRoot({
defaults: {},
plugins: [ Annotation ]
}),
// ...
and then, in your component.ts file:
chartOptions: ChartConfiguration['options'] = {
scales: {
// ...
},
plugins: {
annotation: {
annotations: [
{
type: 'line',
scaleID: 'y',
value: 16,
borderColor: 'green',
borderWidth: 6
},
]
}
},
}