2.0.5 • Published 7 months ago

@explorables/if_you_ask_your_xy v2.0.5

Weekly downloads
-
License
CC-BY-4.0
Repository
github
Last release
7 months ago

If you ask your XY

CC BY 4.0

The XY model is a key model of statistical mechanics. Among other things, it describes self-organization of spatially arranged magnets but also concepts like opinion dynamics in social systems.

The explorable is part of the Complexity Exporables Collection. For more information about the system and its behavior consult the explorable

“If you ask your XY” - The XY-model of statistical mechanics

Usage & Installation

Just running the explorable

If you just want to run the explorable you can Click here.

Running a local copy

If you want to run a local copy without having to rely on the nasty internet, the best way is to install it via npm:

npm install @explorables/if_you_ask_your_xy
open node_modules/@explorables/if_you_ask_your_xy/dist/index.html 

Embedding the explorable in your site

If you want to embed the explorable in your site, you need to do three things:

  1. load the explorable package via <script> tag in your page header
  2. add a <div> container element
  3. add a <script> at the end of the document that loads the explorable

like so:

<!doctype html>
<html>
	<head>
		...
		<script src="https://cdn.jsdelivr.net/npm/@explorables/if_you_ask_your_xy/dist/index.umd.js"></script>
		...
	</head>
		...
	<body>
		...
	    <div id="explorable_container"></div>
		...
	</body>
		...
	<script type="text/javascript">
		const explorable_instance = if_you_ask_your_xy.load("explorable_container")
	</script>
		...
</html>

The header <script> tag loads the bundle, the <div> in the document is the container in which the explorable gets anchored when the function if_you_ask_your_xy("explorable_container") gets executed at the bottom. This function needs the <div> container id as an argument. The function returns an instance of the explorable and writes it to explorable_instance. That variable contains functions like halt(), reset() and variables meta and config.

If you want to make use of ES modules instead of UMD, here's a way that will work on modern (ES support) and legacy browsers (UMD only).

<!doctype html>
<html>
	<head>
		...
	    <script type="module">
	  	      import load from 'https://cdn.jsdelivr.net/npm/@explorables/if_you_ask_your_xy/dist/index.es.js';
	  	      const if_you_ask_your_xy = load("explorable_container");
	    </script>
	    <script nomodule src="https://cdn.jsdelivr.net/npm/@explorables/if_you_ask_your_xy/dist/index.umd.js"></script>	  
		...
	</head>
		...
	<body>
		...
	    <div id="explorable_container"></div>
		...
	</body>
		...
	<script nomodule type="text/javascript">
		const explorable_instance = if_you_ask_your_xy.load("explorable_container")
	</script>
		...
</html>

Installing the whole package locally

If you want to modify or edit the explorable to make your own version:

Clone repository:

git clone https://github.com/dirkbrockmann/if_you_ask_your_xy.git

Go to the directory, install, build and show using npm:

  1. cd if_you_ask_your_xy
  2. npm install
  3. npm run build
  4. npm run preview

License

This work is licensed under a Creative Commons Attribution 4.0 International License.

CC BY 4.0

2.0.3

7 months ago

2.0.2

7 months ago

2.0.5

7 months ago

2.0.4

7 months ago

2.0.1

7 months ago

1.1.5

2 years ago

1.1.4

2 years ago

1.1.3

2 years ago

1.1.2

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago