Hey i am using Apex chart with vue.js
VueApexChart
Here is my option value :
JavaScript
x
34
34
1
export const option = {
2
chartOptions: {
3
chart: {
4
height: 350,
5
type: 'line',
6
zoom: {
7
enabled: false,
8
},
9
toolbar: {
10
show: false,
11
},
12
},
13
dataLabels: {
14
enabled: false,
15
},
16
stroke: {
17
curve: 'straight',
18
},
19
grid: {
20
row: {
21
colors: ['#f3f3f3', 'transparent'],
22
opacity: 0.5,
23
},
24
},
25
yaxis: {
26
type: 'numeric',
27
},
28
xaxis: {
29
type: 'datetime',
30
},
31
32
},
33
};
34
and here in my component data here is my series structure:
JavaScript
1
11
11
1
chartData = [{
2
"name": "Chloride",
3
"data": [{
4
"x": "2021-02-08",
5
"y": 40,
6
}]
7
}, {
8
"name": "M Alkalinity",
9
"data": []
10
}]
11
Then i am having my component called like this:
JavaScript
1
7
1
<apexchart
2
type="line"
3
height="350"
4
:options="chartOptions"
5
:series="chartData"
6
/>
7
Nothing is displayed on the chart
Advertisement
Answer
Running it in a codesandbox works fine. Are you sure it isn’t just because you didn’t have any chart data? (I’ve added some in for the example)
I changed
JavaScript
1
11
11
1
chartData = [{
2
"name": "Chloride",
3
"data": [{
4
"x": "2021-02-08",
5
"y": 40,
6
}]
7
}, {
8
"name": "M Alkalinity",
9
"data": []
10
}]
11
to:
JavaScript
1
38
38
1
export default {
2
data() {
3
return {
4
chartOptions: {
5
//..
6
},
7
series: [
8
{
9
name: "Chloride",
10
data: [
11
{
12
x: "2021-02-08",
13
y: 40,
14
},
15
{
16
x: "2021-02-09",
17
y: 50,
18
},
19
],
20
},
21
{
22
name: "M Alkalinity",
23
data: [
24
{
25
x: "2021-02-08",
26
y: 60,
27
},
28
{
29
x: "2021-02-09",
30
y: 20,
31
},
32
],
33
},
34
],
35
};
36
},
37
};
38