Grpah works, but no lines on it

This commit is contained in:
pswsm 2023-02-15 16:20:45 +01:00
pare a06ea205f6
commit 482d0b0787
S'han modificat 5 arxius amb 84 adicions i 68 eliminacions

Veure arxiu

@ -1,24 +1,37 @@
<script lang="ts"> <script lang="ts">
import highcharts from "./highcharts"; import highcharts from "./highcharts";
export let ubicacio: string = '';
export let series: Array<any> = [];
let config = { let config = {
chart: {
type: 'spline'
},
title: { title: {
text: 'Solar Employment Growth by Sector, 2010-2016' text: `Temps a ${ubicacio}`
}, },
subtitle: { subtitle: {
text: 'Source: thesolarfoundation.com' text: 'Dades: open-meteo.com'
}, },
yAxis: { yAxis: {
title: { title: {
text: 'Number of Employees' text: 'Temperatura'
} }
}, },
xAxis: { xAxis: {
type: 'datetime',
tickInterval: 36e5,
tickLength: 0,
startOnTick: false,
endOnTick: false,
title: {
text: 'Data'
},
accessibility: { accessibility: {
rangeDescription: 'Range: 2010 to 2017' rangeDescription: 'Temps per hores'
} }
}, },
@ -30,13 +43,15 @@ title: {
plotOptions: { plotOptions: {
series: { series: {
label: { marker: {
connectorAllowed: false enabled: true,
}, radius: 2.5
pointStart: 2010 }
} }
}, },
series: series,
/*
series: [{ series: [{
name: 'Installation', name: 'Installation',
data: [43934, 52503, 57177, 69658, 97031, 119931, 137133, 154175] data: [43934, 52503, 57177, 69658, 97031, 119931, 137133, 154175]
@ -52,7 +67,7 @@ title: {
}, { }, {
name: 'Other', name: 'Other',
data: [12908, 5948, 8105, 11248, 8989, 11816, 18274, 18111] data: [12908, 5948, 8105, 11248, 8989, 11816, 18274, 18111]
}], }], */
responsive: { responsive: {
rules: [{ rules: [{

Veure arxiu

@ -1,6 +1,7 @@
<script lang="ts"> <script lang="ts">
import { NavbarObject } from "../classes/NavObject"; import { NavbarObject } from "../classes/NavObject";
import Navbar from "../components/navbar.svelte"; import Navbar from "../components/navbar.svelte";
import './styles.css';
let navbarElemenets: NavbarObject[] = [new NavbarObject('/', 'Home'), new NavbarObject('/temps', 'Temps'), new NavbarObject('/xema', 'Estacions'), new NavbarObject('/openmeteo', 'Dades Open Meteo')] let navbarElemenets: NavbarObject[] = [new NavbarObject('/', 'Home'), new NavbarObject('/temps', 'Temps'), new NavbarObject('/xema', 'Estacions'), new NavbarObject('/openmeteo', 'Dades Open Meteo')]
</script> </script>

Veure arxiu

@ -15,14 +15,11 @@ export function load(): object {
}) })
.then( (res) => { .then( (res) => {
let forecastData: object = res.hourly; let forecastData: object = res.hourly;
let fmtForecastData: { labels: string[], datasets: Array<object> } = { labels: forecastData.time, datasets: [] }; let fmtForecastData: { title: string, data: [Date, number] | [] } = { title: 'Temps', data: [] };
let noTimeForecastData: object = Object.fromEntries(Object.entries(forecastData).filter( ([k]) => k !== 'time' )); let regex: RegExp = /(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2})/
for (const label in noTimeForecastData) { forecastData.time.forEach( (elem, idx) => {
if (noTimeForecastData.hasOwnProperty(label)) { fmtForecastData.data.push([Date.parse(elem), forecastData.temperature_2m[idx]])
const data = noTimeForecastData[label]; });
fmtForecastData.datasets.push({label, data})
}
}
return fmtForecastData; return fmtForecastData;
} ) } )

Veure arxiu

@ -5,7 +5,7 @@
let display: string = 'none'; let display: string = 'none';
let loading: boolean = false; let loading: boolean = false;
export let data: any; export let data: { ubicacio: string, temps: any };
function toggleDisplay(): void { function toggleDisplay(): void {
display = (display === 'none') ? 'block' : 'none'; display = (display === 'none') ? 'block' : 'none';
@ -21,7 +21,7 @@
<h2>Ubicació actual: { data.ubicacio }</h2> <h2>Ubicació actual: { data.ubicacio }</h2>
<button type="button" on:click={toggleDisplay}>Canviar ubicació</button> <button type="button" on:click={toggleDisplay}>Canviar ubicació</button>
<pre>{ JSON.stringify(data) }</pre> <pre>{ JSON.stringify(data) }</pre>
<Graph /> <Graph ubicacio={data.ubicacio} series={data.temps} />
<footer> <footer>
<p>Dades provinents de:</p> <p>Dades provinents de:</p>
<ul> <ul>

3
src/routes/styles.css Normal file
Veure arxiu

@ -0,0 +1,3 @@
body {
margin: 0;
}