accel chart

This commit is contained in:
Niko Feith 2023-02-23 15:46:25 +01:00
parent 4bab401a51
commit c7625c7f2b
5 changed files with 98 additions and 30 deletions

View File

@ -16,7 +16,7 @@
"roslib": "^1.3.0", "roslib": "^1.3.0",
"vue": "^3.2.45", "vue": "^3.2.45",
"vue-resource": "^1.5.3", "vue-resource": "^1.5.3",
"vue-slider-component": "^3.2.24", "vue-slider-component": "^4.1.0-beta.7",
"vue3-slider": "^1.8.0", "vue3-slider": "^1.8.0",
"vuetify": "^3.1.4" "vuetify": "^3.1.4"
}, },

View File

@ -1,11 +1,81 @@
<template> <template>
<div>
<canvas id="policy-chart"/>
</div>
</template> </template>
<script> <script setup>
export default { import { onMounted, watch } from "vue";
name: "PolicyPlot" import { usePStore } from "@/store/PolicyStore";
import { Chart } from 'chart.js/auto';
const store = usePStore();
let chartHandle;
function buildChart() {
const policy = store.getPolicy();
const policy_labels = Array(policy.length).fill(0).map((_, i) => i);
const RewardPlot = {
data: {
datasets: [
{
label: 'Reward',
type: 'line',
xAxisID: 'x',
yAxisID: 'y',
data: policy,
borderColor: '#3DC47A',
borderWidth: 2,
pointRadius: 0,
},
],
},
options: {
maintainAspectRatio: false,
responsive: true,
animation: {
duration: 0,
},
lineTension: 0,
tooltip: {
mode: 'label',
},
scales: {
x: {
grid: {
display: false,
},
labels: policy_labels,
ticks: {
autoSkip: true,
},
},
y:
{
type: 'linear',
ticks: {
beginAtZero: true,
},
},
},
},
};
const ctx = document.getElementById('policy-chart');
// eslint-disable-next-line no-new
chartHandle = new Chart(ctx, RewardPlot);
} }
onMounted(() => {
buildChart();
});
watch(() => store.getPolicy(), () => {
chartHandle.data.dataset[0].data = store.getPolicy();
chartHandle.update();
});
</script> </script>
<style scoped> <style scoped>

View File

@ -2,7 +2,6 @@
<div> <div>
<canvas id="reward-chart"/> <canvas id="reward-chart"/>
</div> </div>
</template> </template>
<script setup> <script setup>

View File

@ -1,9 +1,11 @@
<template> <template>
<weight-tuner/> <weight-tuner/>
<reward-plot/>
</template> </template>
<script setup> <script setup>
import WeightTuner from "@/components/WeightTuner.vue"; import WeightTuner from "@/components/WeightTuner.vue";
import RewardPlot from "@/components/RewardPlot.vue";
</script> </script>
<style scoped> <style scoped>

View File

@ -1,21 +1,16 @@
<template> <template>
<v-card height="200px"> <v-card class="weight-tuner">
<v-row> <v-row no-gutters justify="center">
<v-col v-for="(_, idx) in store.weights" align-self="center"> <v-col v-for="(_, idx) in weights">
<!-- <Vue3Slider v-model="weights[idx]"--> <div class="weight-container">
<!-- :min="-1"--> <vue-slider v-model="weights[idx]"
<!-- :max="1"--> direction="btt"
<!-- :step="0.01"--> :height="100"
<!-- orientation="vertical"--> :min="-1"
<!-- class="weight-slider"--> :max="1"
<!-- />--> :interval="0.01"
<!-- <v-slider v-model="weights[idx]"--> />
<!-- direction="vertical"--> </div>
<!-- :label="idx.toString()"-->
<!-- min="-1" max="1"-->
<!-- :step="0.01"-->
<!-- style="max-height: 200px"-->
<!-- density="comfortable"/>-->
</v-col> </v-col>
</v-row> </v-row>
</v-card> </v-card>
@ -23,22 +18,24 @@
<script setup> <script setup>
import { usePStore } from "@/store/PolicyStore"; import { usePStore } from "@/store/PolicyStore";
import VueSlider from "vue-slider-component"; import VueSlider from "vue-slider-component";
import 'vue-slider-component/theme/default.css';
const store = usePStore() const store = usePStore()
const weights = store.weights; const weights = store.weights;
</script> </script>
<style scoped> <style scoped>
.weight-slider.vue3-slider.vertical { .weight-tuner {
height: 150px; height: 140px;
width: 8px;
} }
.weight-slider { .weight-container {
vertical-align: middle; height: 140px;
display: flex;
align-items: center;
justify-content: center;
} }
</style> </style>