Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <div id="app">
	<div class="container">
		<div class="row">
			<div class="column column-50">
				<div class="">
					<div class="">Référentiel</div>
					<label for="tre">Taux de retour à l'équilibre (TRE) [%]</label>
					<input type="text" id="tre" name="tre" v-model="tre">
					<label for="utr">Unité de Temps de Récurrence (UTR) [s]</label>
					<select id="utr" name="utr" v-model.number="utr">
						<option value="2629800">Mois</option>
						<option value="86400">Jour</option>
						<option value="31557600">Année</option>
					</select>
					<label for="vldi">Limite de crédit maximale - Limite de déséquilibre en importation (VLDI)</label>
					<select id="vldi" name="vldi" v-model.number="vldi">
						<option value="220000">Suisse (220 000)</option>
						<option value="90000">France (90 000)</option>
						<option value="70000">Italie (70 000)</option>
						<option value="10000">Exemple 1 (10 000)</option>
					</select>
					<label for="origine">Origine</label>
					<input type="number" id="origine" name="origine" v-model.number="origine">
					<label for="sens">Sens pour une importation</label>
					<select id="sens" name="sens" v-model.number="sens">
  					<option value="1">sens descriptif (+1)</option>
  					<option value="-1">sens compensatoire (-1)</option>
					</select>
				</div>
					<strong>Revenu récurent - Augmentation du déséquilibre par UTR (AVLDI):</strong> {{avldi}}<br>
					<strong>Part de Liberté Économique (PLE):</strong> {{ple}}
				<div class="">Affichage</div>
				<label for="vpe">Valeur de la position d'équilibre (VPE)</label>
				<select id="vpe" name="vpe" v-model.number="vpe">
					<option value="0">0</option>
					<option :value="vldi">VLDI</option>
					<option :value="origine">Origine</option>
				</select>
				<label for="era">Echelle de l'affichage</label>
				<select id="era" name="era" v-model.number="era">
  				<option :value="avldi">AVLDI ({{avldi}})</option>
						<option value="2200">Suisse (2200)</option>
						<option value="900">France (900)</option>
						<option value="700">Italie (700)</option>
						<option value="100">Exemple 1 (100)</option>
				</select>
				<p>Ratio Référentiel/Echelle d'affichage: {{eraRatio.toFixed(2)}}<br>Pour une valeur de 100 en input: {{valC(100)}} (réf.) → {{valCV(100)}} (affi.)</p>
				<p>Sel compensatoire : 0=VPE, sens compensatoire Sel inventaire : 0=VPE, sens descriptif
bancaire : 0=VLDI, sens compensatoire
tout négatif : 0=VLDI, sens descriptif</p>
			</div>
			<div class="column column-50">
				<apexchart ref="chartSolde" width="100%" height="300" type="line" :options="optionsSolde" :series="seriesSolde"></apexchart>
				<apexchart ref="chartEquil" width="100%" height="300" type="line" :options="optionsEquil" :series="seriesEquil"></apexchart>
				<div>Fonte: {{am}} UTR → {{secondsToYM(am*utr)}}</div>
			</div>
		</div>
	</div>
              
            
!

CSS

              
                
              
            
!

JS

              
                var vm = new Vue({
	el: "#app",
	components: {
		apexchart: VueApexCharts
	},
	data: function() {
		return {
			tre: 1, // Taux de retour à l'équilibre: en pourcentage
			utr: 2629800, // Unité de Temps de Récurrence en secondes: 1mois = 2629800 secondes
			vpe: 0, // Valeur de la Position d'Equilibre : 0 ou VLDI
			origine: 0, // Origine du référentiel
			sens: 1, // Pour une importation : sens compensatoire (-1) ou sens descriptif (+1)
			vldi: 220000, // Valeur de la Limite de Déséquilibre en Importation
			era: 2200, // Echelle du référentiel d'affichage
			optionsEquil: null,
			seriesEquil: null,
			optionsSolde: null,
			seriesSolde: null,
		};
	},
	computed: {
		// Augmentation de la VLDI
		avldi: function() {
			return this.vldi * (this.tre / 100);
		},
		// Part de Liberté Économique
		ple: function() {
			return this.vldi - this.vpe;
		},
		// UTR en mois
		utrm: function() {
			return this.utr / 2629800;
		},
		// Amortissement
		am: function() {
			return Math.round(5 / (this.tre / 100));
		},
		// Rapport de l'échelle du référentiel d'affichage
		eraRatio: function() {
			return (this.era / this.avldi);
		},
	},
	mounted: function() {
		this.updateChartEquil();
		this.updateChartSolde();
	},
	methods: {
		treCalc: function(sSens) {
			if (sSens != undefined) {
				startSens = sSens;
			} else {
				startSens = 1;
			}

			var rate = this.tre / 100;
			var loops = this.am;
			var start = startSens * this.vldi * this.sens;
			var array = [this.valCV(start)];
			var last = start;
			for (var i = 1; i <= loops; i++) {
				var lastI = array[i - 1];
				if (last < 0) {
					last = last + -1 * last * rate;
					array.push(this.valCV(last + -1 * last * rate));
				} else if (last > 0) {
					last = last - last * rate;
					array.push(this.valCV(last - last * rate));
				} else if (last == 0) {
					last = last + this.avldi;
					array.push(this.valCV(last + this.avldi));
				}
			}
			return array;
		},
		updateChartEquil() {
			this.seriesEquil = [{ data: this.treCalc(-1), name: "Fonte" }];
			this.optionsEquil = {
				chart: {
					id: "vuechart-equil",
					toolbar: {
						show: true,
						tools: {
							download: true,
							selection: false,
							zoom: false,
							zoomin: false,
							zoomout: false,
							pan: false,
							reset: true
						}
					}
				},
				title: {
					text: "Retour à l'équilibre",
					align: "center"
				},
				markers: {
					size: 0,
					colors: undefined,
					strokeColor: "#fff",
					strokeWidth: 1,
					strokeOpacity: 0.9,
					fillOpacity: 1,
					discrete: [],
					shape: "circle",
					radius: 2,
					hover: {
						size: undefined,
						sizeOffset: 3
					}
				},
				annotations: {
					yaxis: [
						{
							y: this.vpe,
							borderColor: "#00E396",
							label: {
								borderColor: "#00E396",
								style: {
									color: "#fff",
									background: "#00E396"
								},
								text:
									"VPE: " + this.vpe.toString().replace(/\B(?=(\d{3})+(?!\d))/g, " ")
							}
						}
					]
				},
				xaxis: {
					title: {
						text: "UTR",
						offsetY: -10
					}
				},
				yaxis: {
					labels: {
						formatter: function(value, timestamp, index) {
							return Math.round(value) / 1000 + "K";
						}
					},
					title: {
						text: "Solde",
						offsetY: 10
					}
				}
			};
		},
		updateChartSolde() {
			this.seriesSolde = [
				{
					data: [
						this.valCV(0),
						this.valCV(-1000),
						this.valCV(-2200),
						this.valCV(-20000),
						this.valCV(-this.vldi),
						this.valCV(-this.vldi + this.avldi),
						this.valCV(-this.vldi + 10000),
						this.valCV(1000),
						this.valCV(10000),
						this.valCV(30000),
					],
					name: "Solde net"
				},
				{
					data: [
						this.val(0),
						this.val(-1000),
						this.val(-2200),
						this.val(-20000),
						this.val(-this.vldi),
						this.val(-this.vldi + this.avldi),
						this.val(-this.vldi + 10000),
						this.val(1000),
						this.val(10000),
						this.val(30000),
					],
					name: "Valeurs brutes"
				}
			];
			this.optionsSolde = {
				chart: {
					id: "vuechart-solde",
					toolbar: {
						show: true,
						tools: {
							download: true,
							selection: false,
							zoom: false,
							zoomin: false,
							zoomout: false,
							pan: false,
							reset: true
						}
					}
				},
				title: {
					text: "Evolution du solde",
					align: "center"
				},
				xaxis: {
					title: {
						text: "Transactions",
						offsetY: -10
					}
				},
				yaxis: {
					labels: {
						formatter: function(value, timestamp, index) {
							return Math.round(value)
								.toString()
								.replace(/\B(?=(\d{3})+(?!\d))/g, " ");
						}
					},
					title: {
						text: "Solde",
						offsetY: 10
					}
				},
				annotations: {
					yaxis: [
						{
							y: this.vpe,
							borderColor: "#00E396",
							label: {
								borderColor: "#00E396",
								style: {
									color: "#fff",
									background: "#00E396"
								},
								text:
									"VPE: " + this.vpe.toString().replace(/\B(?=(\d{3})+(?!\d))/g, " ")
							}
						},
					],
					xaxis: [
						{
							x: 6,
							label: {
								borderColor: "#FF4560",
								offsetY: 0,
								style: {
									color: "#fff",
									background: "#FF4560"
								},
								text: "TRE: " + this.tre + "%"
							}
						}
					]
				}
			};
		},
		secondsToYM(input) {
			input = Number(input);
			var y = (input / 31557600);
			var yf = Math.floor(input / 31557600);
			var m = ((y-yf) / 2629800);
			var mf = Math.floor(m);
			var mi = parseInt(m);
			
			var yD = yf > 0 ? yf + (yf == 1 ? " an" : " ans") : "";
			var yS = mi > 0 ? " et " : "";
			var mD = mi > 0 ? mi + (mi == 1 ? " mois" : " mois") : "";
			return yD + yS + mD;
		},
		secondsToY(input) {
			input = Number(input);
			var y = Math.floor(input / 31557600);

			var yDisplay = y > 0 ? y + (y == 1 ? " an" : " ans") : "";
			return yDisplay;
		},
		secondsToM(input) {
			input = Number(input);
			var mo = Math.floor(input / 2629800);
			var moDisplay = mo > 0 ? mo + (mo == 1 ? " moi" : " mois") : "";
			return moDisplay;
		},
		// Value
		val(val) {
			val = Number(val);
			return val;
		},
		// Value calculation
		valC(val) {
			val = Number(val);
			let o = this.origine;
			let s = this.sens;
			let e = this.avldi;
			let value = ((val/e)+o)*s;
			return value;
		},
		// Value calculation for view
		valCV(val) {
			val = Number(val);
			let o = this.origine;
			let s = this.sens;
			let e = this.avldi;
			let equil = this.vpe;
			let era = this.era;
			let scaleRatio = this.eraRatio;
			let value = Math.round(((val*scaleRatio)+o+equil)*s);
			return value;
		}
	},
	watch: {
		origine() {
			console.log("up-origine: " + this.origine);
			this.updateChartEquil();
			this.updateChartSolde();
		},
		era() {
			console.log("era-origine: " + this.era);
			this.updateChartEquil();
			this.updateChartSolde();
		},
		vpe() {
			console.log("up-vpe: " + this.vpe);
			this.updateChartEquil();
			this.updateChartSolde();
		},
		sens() {
			console.log("up-sens: " + this.sens);
			this.updateChartEquil();
			this.updateChartSolde();
		},
		tre() {
			console.log("up-tre: " + this.tre);
			this.updateChartEquil();
		},
		vldi() {
			console.log("up-vldi: " + this.vldi);
			this.updateChartEquil();
			this.updateChartSolde();
		},
		utr() {
			console.log("up-utr: " + this.utr);
			this.updateChartEquil();
			this.updateChartSolde();
		}
	}
});

              
            
!
999px

Console