-
Notifications
You must be signed in to change notification settings - Fork 240
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
255 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# Generated by Django 5.1.1 on 2024-11-29 09:46 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
dependencies = [ | ||
("core", "0042_asset_filtering_labels"), | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name="HistoricalMetric", | ||
fields=[ | ||
( | ||
"id", | ||
models.BigAutoField( | ||
auto_created=True, | ||
primary_key=True, | ||
serialize=False, | ||
verbose_name="ID", | ||
), | ||
), | ||
("date", models.DateField(db_index=True, verbose_name="Date")), | ||
("data", models.JSONField(verbose_name="Historical Data")), | ||
("model", models.TextField(db_index=True, verbose_name="Model")), | ||
( | ||
"object_id", | ||
models.UUIDField(db_index=True, verbose_name="Object ID"), | ||
), | ||
( | ||
"updated_at", | ||
models.DateTimeField(auto_now=True, verbose_name="Updated at"), | ||
), | ||
], | ||
options={ | ||
"indexes": [ | ||
models.Index( | ||
fields=["model", "object_id", "date"], | ||
name="core_histor_model_e05191_idx", | ||
), | ||
models.Index( | ||
fields=["date", "model"], name="core_histor_date_ddb7df_idx" | ||
), | ||
], | ||
"unique_together": {("model", "object_id", "date")}, | ||
}, | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
<script lang="ts"> | ||
import { onMount } from 'svelte'; | ||
export let width = 'w-auto'; | ||
export let height = 'h-full'; | ||
export let classesContainer = ''; | ||
export let title = ''; | ||
export let name = ''; | ||
export let timeseries = []; | ||
const chart_id = `${name}_div`; | ||
onMount(async () => { | ||
const echarts = await import('echarts'); | ||
let chart_t = echarts.init(document.getElementById(chart_id), null, { renderer: 'svg' }); | ||
// specify chart configuration item and data | ||
var option = { | ||
grid: { show: false }, | ||
tooltip: { | ||
trigger: 'axis', | ||
formatter: function (params) { | ||
return ( | ||
new Date(params[0].value[0]).toLocaleDateString() + | ||
'<br/>' + | ||
params[0].marker + | ||
params[0].seriesName + | ||
': ' + | ||
params[0].value[1] | ||
); | ||
} | ||
}, | ||
xAxis: { | ||
type: 'time', | ||
splitNumber: 3, | ||
axisPointer: { | ||
snap: true | ||
} | ||
}, | ||
yAxis: { | ||
type: 'value', | ||
boundaryGap: [0, '5%'], | ||
splitLine: { show: false } | ||
}, | ||
series: [ | ||
{ | ||
name: 'Requirements assessed', | ||
type: 'line', | ||
symbol: 'none', | ||
areaStyle: { | ||
opacity: 0.8, | ||
color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [ | ||
{ | ||
offset: 0, | ||
color: 'rgb(55, 162, 255)' | ||
}, | ||
{ | ||
offset: 1, | ||
color: 'rgba(55, 162, 255, 0.1)' | ||
} | ||
]) | ||
}, | ||
smooth: true, | ||
data: [ | ||
['2024-11-22', 36], | ||
['2024-11-23', 37] | ||
] | ||
} | ||
] | ||
}; | ||
chart_t.setOption(option); | ||
window.addEventListener('resize', function () { | ||
chart_t.resize(); | ||
}); | ||
}); | ||
</script> | ||
|
||
<div | ||
id={chart_id} | ||
class="{height} {width} {classesContainer}" | ||
style="width: 400px; height:400px;" | ||
/> |
11 changes: 11 additions & 0 deletions
11
frontend/src/routes/(app)/(internal)/experimental/timeseries/+page.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<script lang="ts"> | ||
import type { PageData } from './$types'; | ||
export let data: PageData; | ||
import TimeSeriesChart from '$lib/components/Chart/TimeSeriesChart.svelte'; | ||
</script> | ||
|
||
<div class="bg-white p-6 shadow flex overflow-x-auto"> | ||
<div class="w-full h-96"> | ||
<TimeSeriesChart /> | ||
</div> | ||
</div> |