1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- <template>
- <div>
- <div :id="id" :options="options"></div>
- </div>
- </template>
- <script>
- import HighCharts from 'highcharts';
- export default {
- // 验证类型
- props: {
- id: {
- type: String
- },
- options: {
- type: Object
- }
- },
- data() {
- return {
- title: "积分趋势图",
- chart: null
- }
- },
- mounted() {
- this.chart = HighCharts.chart(this.id, this.options)
- },
- methods: {
- updateData: function (data) {
- if (!data) {
- return
- }
- while (this.chart.series.length > 0) {
- this.chart.series[0].remove()
- }
- if (data.filter_text) {
- let filterText = data.filter_text
- let titleSuffix = "( " + filterText.time_range + ")"
- if (filterText.employee) {
- titleSuffix += "・" + filterText.employee
- }
- if (filterText.dept) {
- titleSuffix += "・" + filterText.dept
- }
- if (filterText.category) {
- titleSuffix += "・" + filterText.category
- }
- this.chart.setTitle({text: this.title + titleSuffix})
- }
- if (data.chart) {
- let chartData = data.chart
- this.chart.xAxis[0].setCategories(chartData.labels)
- this.chart.addSeries({
- name: "奖分",
- data: chartData.p_positive.map(Number)
- })
- this.chart.addSeries({
- name: "扣分",
- data: chartData.p_negative.map(Number)
- })
- }
- }
- }
- }
- </script>
|