Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set site-wide defaults (using NPM / module-based JS) #493

Open
Michael-Paragonn opened this issue Jul 4, 2023 · 0 comments
Open

Set site-wide defaults (using NPM / module-based JS) #493

Michael-Paragonn opened this issue Jul 4, 2023 · 0 comments

Comments

@Michael-Paragonn
Copy link

Michael-Paragonn commented Jul 4, 2023

I've pored over #105 but can't figure it out, and it's over 3 years old, and it's related to Vue, not plain vanilla JS, so I'm asking pretty much the same question here. ;)

In my main.js file, I have this:

import ApexCharts from 'apexcharts';
window.ApexCharts = ApexCharts;
window.Apex.options = {
	chart:
	{
		height: 350,
		type: 'radialBar',
	},
	plotOptions:
	{
		radialBar:
		{
			hollow:
			{
				size: '70%',
			}
		},
	}
};

In my HTML output (with the variables dynamically set by Twig), I have this:

<div class="chart-01"></div>
<script>
	var options = {
		series: ["42"],
		labels: ['A radial chart!'],
		colors: ['#bada55']
	};

	var chart = new ApexCharts(document.querySelector(".chart-01"), options);
	chart.render();
</script>

This results in a console error that the script Cannot read properties of undefined (reading 'type').

I feel like the fix is pretty simple, but I just don't have the JS-fu to figure it out. Can someone help?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant