[+] Create pie graph component

This commit is contained in:
Hykilpikonna
2019-11-09 22:29:19 -05:00
parent c807d4aecb
commit 963df01b6f
2 changed files with 79 additions and 0 deletions
+71
View File
@@ -0,0 +1,71 @@
import {Component, Prop, Vue} from 'vue-property-decorator';
import Constants from '@/constants';
import {FormatUtils} from '@/logic/utils/format-utils';
import moment from 'moment';
import Course, {Assignment} from '@/logic/course';
import GraphUtils from '@/logic/utils/graph-utils';
@Component
export default class TypePie extends Vue
{
@Prop({required: true}) course: Course;
/**
* Override options
*
* @param options Original options (Unused)
*/
afterConfig(options: any)
{
return this.chartSettings;
}
/**
* Generate settings
*/
get chartSettings()
{
// Create settings
let settings =
{
...GraphUtils.getBaseSettings('Type Radar',
'Assignment type grades for ' + this.course.name),
tooltip: {},
// Data
series:
{
type: 'radar',
data:
[
{
name: 'Score',
symbol: 'circle',
areaStyle:
{
color:
{
type: 'radial',
x: 0.5, y: 0.6, r: 0.5,
colorStops:
[
{offset: 0, color: '#ffa0a0'},
{offset: 0.5, color: '#fffead'},
{offset: 1, color: '#d1ffde'}
],
global: false // 缺省为 false
},
opacity: 0.2
},
value: this.course.assignmentTypes.map(t => t.percent)
}
]
},
color: '#6771c1'
};
return settings;
}
}
+8
View File
@@ -0,0 +1,8 @@
<template>
<div id="type-pie">
<ve-pie height="450px" class="graph" :extend="{a: this.course.name}" :after-config="afterConfig"></ve-pie>
</div>
</template>
<script src="./type-pie.ts" lang="ts"></script>
<style lang="scss" scoped></style>