VNWG7QG3VM3JCF3QQ4OJAY2RFBKBWZ7JJNAISIP6YIIX6L2LGBUQC 3O3IMVFKGSXMVLPLZR3H6MIG3EE5PS4632QE4JMK5SVX2PVSSKDAC 7MCTB5G2W6IB7JQXGO2HCMRHBUYIOKXI4MBODKLAJIK66EMLC5ZQC LX2ZVNAYX2FRCEIJ6XBCBILB3O7YT52AP56QDWCCGLATFCEB7KHQC 6NB2PU2F64XDSURKYMBECKEN7ZQ63RMDN2GL5CP74YA6HE4K3TTAC O63TXA57OHFIPUDT4QQBDVXRQA64CUIT7XU4G6MSQPMDRFJPM7IAC QHVOZBISIQ3E3P5F6GGKWVDSXC4OA23HCIH2OMXEVGXKSF5W4APAC O22SKNQ6LUA45DZ7QFM3RFAMC2X64WMRITU4N5K22CWNGHIYFLJAC XTA7M7PSEN3PURH4ARXUMZ3PMEQRVX7FPRQA6LANFVI776LJGELQC UPNRAOJN5TKYIAQIWTX2MURHUEIPHA2MJKAQOFCDL2PQSGK35OCQC O4ALNQWBOXUOZRVT6J7C64I4BNJMHIO44ZWNEWIOUBCLE2C7JBAQC 3WWWPCD6BDUHGDTIQHSVUSETNZCM56FYV5EDE2XIH3BNSXBUIKLQC UWD234SIIBCA45TXXSOSZEWLUF66NFPWET257C3WZQYX3L5EJPCAC C56DYYC72SFNR6BSKCOVDY2QW6XNP66EUGGKCBROTCFJVQDB4FUAC P7KZ25R4CNS4PZITRWPBVXRFSLY5TKCOFO6U3SDKX45ITNVU773QC NPDXW2TQMOKQL233633EHOJX4VYQGY5IVIHTRFLZSPG32CNX3XXAC 6NRS3ZPPZ6A42IEDMRLQ7LZ5TPPLFQ6AGYVS32TQRGHBIJQW4WBAC let auto = 0let totalProd = 0let totalConso = 0let soleil = {hourly: {x: <string[]>[],y: <number[]>[],},daily: {x: <string[]>[],y: <number[]>[],},weekly: {x: <string[]>[],y: <number[]>[],},
let auto = 0let totalProd = 0let totalConso = 0let somme: Sample = {hourly: {x: <string[]>[],y: <number[]>[],},daily: {
type: 'bar',line: {color: '#ffbf00',width: 1,},marker: {color: '#ffbf00',width: 1,},name: 'Production solaire',bucket: 1,}let somme = {hourly: {x: <string[]>[],y: <number[]>[],},daily: {x: <string[]>[],y: <number[]>[],},weekly: {x: <string[]>[],y: <number[]>[],},
},weekly: {
type: 'bar',line: {color: '#b81111',width: 1,},marker: {color: '#b81111',width: 1,},name: 'Consommation totale',bucket: 1,
},x: <string[]>[],y: <number[]>[],type: 'bar',line: {color: '#b81111',width: 1,},marker: {color: '#b81111',width: 1,},name: 'Consommation totale',bucket: 1,}async function updatePv(puissance: number,communaute: (Grain.Communaute&{isMoving?: boolean}) | null,) {if(communaute?.isMoving) {return pvgis
async function updatePv(puissance: number,communaute: (Grain.Communaute&{isMoving?: boolean}) | null,) {if(communaute?.isMoving) {return pvgis}pvgis_loading = truepvgis = await calcul.updatePv(puissance, communaute, pvgis, soleil, base)pvgis_loading = falseawait tick()
async function updatePlot(puissance: number,communaute: (Grain.Communaute & { isMoving?: boolean }) | null,) {console.log("isMoving", communaute?.isMoving)if(communaute?.isMoving) {return
await updatePv(puissance, communaute)console.log("updated")prm_loading = true;let auto_ = await calcul.updatePlot(assets,annee,data.profils,profils_,somme,soleil,)prm_loading = false;await tick()auto = auto_.autototalProd = auto_.totalProdtotalConso = auto_.totalConsoconsole.log("updated auto", auto, totalProd, totalConso)if (!Plotly)//@ts-ignorePlotly = await import('plotly.js-dist')
async function updatePlot(puissance: number,communaute: (Grain.Communaute & { isMoving?: boolean }) | null,) {console.log("isMoving", communaute?.isMoving)if(communaute?.isMoving) {return}if (!browser) {return}
await tick()redraw()}
await updatePv(puissance, communaute)console.log("updated")prm_loading = true;let auto_ = await calcul.updatePlot(assets,annee,data.profils,profils_,somme,soleil,)prm_loading = false;await tick()auto = auto_.autototalProd = auto_.totalProdtotalConso = auto_.totalConsoconsole.log("updated auto", auto, totalProd, totalConso)if (!Plotly)//@ts-ignorePlotly = await import('plotly.js-dist')
let has_plot = { has_plot: false };let layout = {};
await tick()redraw()
function relayout_(event: any) {console.log('relayout_')const plot = document.getElementById('plot')!relayout(event, plot, Plotly, layout, has_plot, get(soleil), somme)}function redraw() {console.log("redraw")const plot = document.getElementById('plot')if (!plot) returnlet soleil_ = get(soleil)chooseScale(soleil_)chooseScale(somme)let unite: stringif (soleil_.bucket == 24) {unite = 'kWh/jour'} else if (soleil_.bucket == 24 * 7) {unite = 'kWh/semaine'} else {unite = 'kWh'}layout = {title: 'Autoconsommation',autosize: true,automargin: true,plot_bgcolor: '#fff0',paper_bgcolor: '#fff0',font: {color: darkMode ? '#fff' : '#000',},xaxis: {gridcolor: darkMode ? '#444' : '#bbb',ticklabeloverflow: 'allow',ticklabelstep: 4,tickangle: 45,},yaxis: {title: { text: unite },gridcolor: darkMode ? '#444' : '#bbb',color: darkMode ? '#fff' : '#000',},showlegend: true,legend: {xanchor: 'center',x: 0.5,y: -0.4,orientation: 'h',},}plotStyle = 'min-height:450px'if (has_plot.has_plot) {Plotly!.update(plot, [soleil_, somme], layout)} else {Plotly!.newPlot(plot, [soleil_, somme], layout, {responsive: true,modeBarButtonsToRemove: modeBarButtonsToRemove,})//@ts-ignoreplot.on('plotly_relayout', relayout_)has_plot.has_plot = true
let has_plot = { has_plot: false };let layout = {};
var dataProd = [{values: [Math.round(auto), Math.round(totalProd - auto)],labels: ['Autoconsommé', 'Surplus'],marker: { colors: ['#ffbf00dd', '#b81111dd'] },type: 'pie',sort: false,hole: 0.5,},]
function relayout_(event: any) {console.log('relayout_')const plot = document.getElementById('plot')!relayout(event, plot, Plotly, layout, has_plot, soleil, somme)}
var dataConso = [{values: [Math.round(auto), Math.round(totalConso - auto)],labels: ['Autoproduit', 'Fournisseur'],marker: { colors: ['#ffbf00dd', '#b81111dd'] },type: 'pie',sort: false,hole: 0.5,},]
function redraw() {console.log("redraw")const plot = document.getElementById('plot')if (!plot) returnchooseScale(soleil)chooseScale(somme)let unite: stringif (soleil.bucket == 24) {unite = 'kWh/jour'} else if (soleil.bucket == 24 * 7) {unite = 'kWh/semaine'} else {unite = 'kWh'}layout = {title: 'Autoconsommation',autosize: true,automargin: true,plot_bgcolor: '#fff0',paper_bgcolor: '#fff0',
plotStyle = 'min-height:450px'Plotly.react('autoProd',dataProd,{title: "Autoconsommation sur l'année",
},}plotStyle = 'min-height:450px'if (has_plot.has_plot) {Plotly!.update(plot, [soleil, somme], layout)} else {Plotly!.newPlot(plot, [soleil, somme], layout, {responsive: true,modeBarButtonsToRemove: modeBarButtonsToRemove,})//@ts-ignoreplot.on('plotly_relayout', relayout_)has_plot.has_plot = true}var dataProd = [{values: [Math.round(auto), Math.round(totalProd - auto)],labels: ['Autoconsommé', 'Surplus'],marker: { colors: ['#ffbf00dd', '#b81111dd'] },type: 'pie',sort: false,hole: 0.5,},]var dataConso = [{values: [Math.round(auto), Math.round(totalConso - auto)],labels: ['Autoproduit', 'Fournisseur'],marker: { colors: ['#ffbf00dd', '#b81111dd'] },type: 'pie',sort: false,hole: 0.5,},]plotStyle = 'min-height:450px'Plotly.react('autoProd',dataProd,{title: "Autoconsommation sur l'année",font: {color: darkMode ? '#fff' : '#000',},plot_bgcolor: '#fff0',paper_bgcolor: '#fff0',autosize: true,legend: {orientation: 'h',},},{ responsive: true })Plotly.react('autoConso',dataConso,{title: "Autoproduction sur l'année",font: {color: darkMode ? '#fff' : '#000',},plot_bgcolor: '#fff0',paper_bgcolor: '#fff0',autosize: true,legend: {orientation: 'h',},
<div class="row my-2"><div class="col-3 d-flex align-middle"><label class="ms-auto form-label" for="prm-{i}">Relevé au format CSV</label></div><div class="col d-flex align-items-center"><inputclass="form-control form-control-sm"id="releve-{i}"bind:value={prm.releve}type="file" /></div></div>
!pvgis ||pvgis.inputs.location.latitude != lat ||pvgis.inputs.location.longitude != lng ||pvgis.inputs.mounting_system.fixed.slope['value'] != inclinaison ||pvgis.inputs.mounting_system.fixed.azimuth['value'] != azimuth
!pvgis_.pvgis ||pvgis_.pvgis.inputs.location.latitude != lat ||pvgis_.pvgis.inputs.location.longitude != lng ||pvgis_.pvgis.inputs.mounting_system.fixed.slope['value'] != inclinaison ||pvgis_.pvgis.inputs.mounting_system.fixed.azimuth['value'] != azimuth
let annuelle = await fetch(`${base}/pvgis?lat=${lat}&lng=${lng}&azimuth=${azimuth}&inclinaison=${inclinaison}`)pvgis = await annuelle.json()
let annuelle = await fetch(`${base}/pvgis?lat=${lat}&lng=${lng}&azimuth=${azimuth}&inclinaison=${inclinaison}`)pvgis_.pvgis = await annuelle.json()pvgis_.loading = false;pvgis.set(pvgis_)
return sample(min_t, max_t, annee_, somme, soleil, {formatMatcher: "month, year",})
let auto = {auto: 0, totalProd: 0, totalConso: 0}soleil.update((sol) => {auto = sample(min_t, max_t, annee_, somme, sol, {formatMatcher: "month, year",});return sol})return auto
let prodWeekly: number[] = []
const soleil: Writable<Sample> = getContext("soleil")const pvgis: Writable<{ pvgis: PVGIS | null, loading: boolean }> = getContext("pvgis")
setContext("pvgis", writable({ pvgis: null, loading: false }))setContext("soleil", writable({hourly: {x: <string[]>[],y: <number[]>[],},daily: {x: <string[]>[],y: <number[]>[],},weekly: {x: <string[]>[],y: <number[]>[],},x: <string[]>[],y: <number[]>[],type: 'bar',line: {color: '#ffbf00',width: 1,},marker: {color: '#ffbf00',width: 1,},name: 'Production solaire',bucket: 1,}))