Skip to content
This repository was archived by the owner on Apr 8, 2020. It is now read-only.

Commit

Permalink
Merge pull request #1845 from shgtkshruch/feat/improve-graph-color
Browse files Browse the repository at this point in the history
fix: グラフのカラー修正
  • Loading branch information
halsk authored Mar 19, 2020
2 parents 975454d + a296cbe commit 043f063
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 7 deletions.
2 changes: 1 addition & 1 deletion components/AgencyBarChart.vue
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import VueI18n from 'vue-i18n'
import { ThisTypedComponentOptionsWithRecordProps } from 'vue/types/options'
import agencyData from '@/data/agency.json'
import DataView from '@/components/DataView.vue'
import { triple as colors } from '@/utils/colors'
interface HTMLElementEvent<T extends HTMLElement> extends Event {
currentTarget: T
Expand Down Expand Up @@ -114,7 +115,6 @@ const options: ThisTypedComponentOptionsWithRecordProps<
},
computed: {
displayData() {
const colors = ['#008b41', '#63c765', '#a6e29f']
const borderColor = '#ffffff'
const borderWidth = [
{ left: 0, top: 1, right: 0, bottom: 0 },
Expand Down
2 changes: 1 addition & 1 deletion components/MetroBarChart.vue
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import Vue from 'vue'
import { ChartOptions, ChartData } from 'chart.js'
import { ThisTypedComponentOptionsWithRecordProps } from 'vue/types/options'
import DataView from '@/components/DataView.vue'
import { triple as colors } from '@/utils/colors'
interface HTMLElementEvent<T extends HTMLElement> extends Event {
currentTarget: T
Expand Down Expand Up @@ -121,7 +122,6 @@ const options: ThisTypedComponentOptionsWithRecordProps<
},
computed: {
displayData() {
const colors: string[] = ['#a6e29f', '#63c765', '#008b41']
const datasets = this.chartData.labels!.map((label, i) => {
return {
label,
Expand Down
5 changes: 3 additions & 2 deletions components/TimeBarChart.vue
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import { GraphDataType } from '@/utils/formatGraph'
import DataView from '@/components/DataView.vue'
import DataSelector from '@/components/DataSelector.vue'
import DataViewBasicInfoPanel from '@/components/DataViewBasicInfoPanel.vue'
import { single as color } from '@/utils/colors'
type Data = {
dataKind: 'transition' | 'cumulative'
Expand Down Expand Up @@ -168,7 +169,7 @@ const options: ThisTypedComponentOptionsWithRecordProps<
data: this.chartData.map(d => {
return d.transition
}),
backgroundColor: '#00B849',
backgroundColor: color,
borderWidth: 0
}
]
Expand All @@ -182,7 +183,7 @@ const options: ThisTypedComponentOptionsWithRecordProps<
data: this.chartData.map(d => {
return d.cumulative
}),
backgroundColor: '#00B849',
backgroundColor: color,
borderWidth: 0
}
]
Expand Down
6 changes: 3 additions & 3 deletions components/TimeStackedBarChart.vue
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ import { TranslateResult } from 'vue-i18n'
import DataView from '@/components/DataView.vue'
import DataSelector from '@/components/DataSelector.vue'
import DataViewBasicInfoPanel from '@/components/DataViewBasicInfoPanel.vue'
import { double as colors } from '@/utils/colors'
interface HTMLElementEvent<T extends HTMLElement> extends Event {
currentTarget: T
Expand Down Expand Up @@ -175,7 +176,6 @@ const options: ThisTypedComponentOptionsWithRecordProps<
}
},
displayData() {
const colorArray = ['#00A040', '#00D154']
const borderColor = '#ffffff'
const borderWidth = [
{ left: 0, top: 1, right: 0, bottom: 0 },
Expand All @@ -188,7 +188,7 @@ const options: ThisTypedComponentOptionsWithRecordProps<
return {
label: this.items[index],
data: item,
backgroundColor: colorArray[index],
backgroundColor: colors[index],
borderColor,
borderWidth: borderWidth[index]
}
Expand All @@ -201,7 +201,7 @@ const options: ThisTypedComponentOptionsWithRecordProps<
return {
label: this.items[index],
data: this.cumulative(item),
backgroundColor: colorArray[index],
backgroundColor: colors[index],
borderColor,
borderWidth: borderWidth[index]
}
Expand Down
4 changes: 4 additions & 0 deletions utils/colors.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export const single: string = '#006400'
export const double: string[] = ['#006400', '#1B75BC']
export const triple: string[] = ['#00441B', '#006400', '#1B75BC']
export const quadruple: string[] = ['#00441B', '#006400', '#1B75BC', '#505B00']

0 comments on commit 043f063

Please sign in to comment.