I am using .net7.0 web app where js are added like bellow, I can use bar chart but I need gauge chart and when I am changing the type getting this error in the console, it says import { GaugeChart }, but in my approach how to do it, by the way just adding echarts.js in the plain html and it is working with my example but in my project not.
[ECharts] Series gauge is used but not imported.
import { GaugeChart } from 'echarts/charts';
echarts.use([GaugeChart]);
if (_runtimeState.Level == RuntimeLevel.Run)
{
_runtimeMinifier.CreateJsBundle("dependency-js-bundle",
bundlingOptions,
"~/lib/vue/vue.global.min.js",
"~/lib/axios/axios.min.js",
"~/lib/lodash.js/lodash.min.js",
"~/lib/echarts/echarts.js",
"~/lib/echarts/echarts.common.js",
"~/lib/echarts/echarts.simple.js",
"~/lib/simplebar/simplebar.min.js",
"~/lib/glightbox/js/glightbox.min.js"); // Other libraries
and I have a section where I am using vue js using Vue.createApp for each page like:
if (document.getElementById("comma-dashboard")) {
let dashboardFinder = Vue.createApp({
mounted() {this.init();},
methods: {
init() {
this.$nextTick(() => {
let attempts = 0;
let maxAttempts = 10; // Stop after 10 attempts (~2 sec)
let waitForMain = setInterval(() => {
let chartContainer = document.getElementById("main");
if (chartContainer) {
clearInterval(waitForMain); // Stop checking once found
var myChart = echarts.init(chartContainer);
var option = {
series: [
{
type: 'gauge',
center: ['50%', '60%'],
startAngle: 200,
endAngle: -20,
min: 0,
max: 60,
splitNumber: 12,
itemStyle: {
color: '#FFAB91'
},
progress: {
show: true,
width: 30
},
pointer: {
show: false
},
axisLine: {
lineStyle: {
width: 30
}
},
axisTick: {
distance: -45,
splitNumber: 5,
lineStyle: {
width: 2,
color: '#999'
}
},
splitLine: {
distance: -52,
length: 14,
lineStyle: {
width: 3,
color: '#999'
}
},
axisLabel: {
distance: -20,
color: '#999',
fontSize: 20
},
anchor: {
show: false
},
title: {
show: false
},
detail: {
valueAnimation: true,
width: '60%',
lineHeight: 40,
borderRadius: 8,
offsetCenter: [0, '-15%'],
fontSize: 60,
fontWeight: 'bolder',
formatter: '{value} L',
color: 'inherit'
},
data: [
{
value: 30
}
]
}
]
};
myChart.setOption(option, true);
} else {
console.warn(`Attempt ${attempts + 1}: #main not found`);
attempts++;
if (attempts >= maxAttempts) {
clearInterval(waitForMain);
console.error("Failed to find #main after multiple attempts.");
}
}
}, 1200); // Check every 200ms
});
}
}
});
dashboardFinder.mount('#comma-dashboard');
}
html looks like this
@{ Layout = "Master.cshtml";}
<div class="b2b-screens fix-screen-size" id="comma-dashboard">
<div id="main" style="width: 600px;height:400px;"></div>
</div
Like this working