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

Commit

Permalink
Merge branch 'development' into feature/dev-map
Browse files Browse the repository at this point in the history
  • Loading branch information
actions-user committed Mar 26, 2020
2 parents d0802af + 703796a commit da68437
Show file tree
Hide file tree
Showing 10 changed files with 188 additions and 23 deletions.
8 changes: 7 additions & 1 deletion components/AgencyBarChart.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<data-view :title="title" :title-id="titleId" :date="date">
<data-view :title="title" :title-id="titleId" :date="date" :url="url">
<template v-slot:infoPanel>
<small :class="$style.DataViewDesc">
<slot name="description" />
Expand Down Expand Up @@ -83,6 +83,7 @@ type Props = {
titleId: string
chartId: string
unit: string
url: string
}
const options: ThisTypedComponentOptionsWithRecordProps<
Expand Down Expand Up @@ -116,6 +117,11 @@ const options: ThisTypedComponentOptionsWithRecordProps<
type: String,
required: false,
default: ''
},
url: {
type: String,
required: false,
default: ''
}
},
data() {
Expand Down
1 change: 0 additions & 1 deletion components/DataView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@
</v-icon>
</a>
</div>
>>>>>>> 5579f794acb8d503d39efddbea4aa824f7566da4
<div>
<a class="Permalink" :href="permalink()">
<time :datetime="formattedDate">
Expand Down
15 changes: 13 additions & 2 deletions components/TimeBarChart.vue
Original file line number Diff line number Diff line change
Expand Up @@ -270,11 +270,18 @@ const options: ThisTypedComponentOptionsWithRecordProps<
fontSize: 9,
maxTicksLimit: 20,
fontColor: '#808080',
maxRotation: 0,
minRotation: 0,
callback: (label: string) => {
return label.split('/')[1]
}
},
type: 'time',
time: {
displayFormats: {
day: 'D'
},
parser: 'M/D',
unit: 'day'
}
},
{
Expand Down Expand Up @@ -325,7 +332,11 @@ const options: ThisTypedComponentOptionsWithRecordProps<
},
type: 'time',
time: {
unit: 'month'
unit: 'month',
parser: 'M/D',
displayFormats: {
month: 'MMM'
}
}
}
],
Expand Down
15 changes: 13 additions & 2 deletions components/TimeStackedBarChart.vue
Original file line number Diff line number Diff line change
Expand Up @@ -322,10 +322,17 @@ const options: ThisTypedComponentOptionsWithRecordProps<
maxTicksLimit: 20,
fontColor: '#808080',
maxRotation: 0,
minRotation: 0,
callback: (label: string) => {
return label.split('/')[1]
}
},
type: 'time',
time: {
displayFormats: {
day: 'D'
},
parser: 'M/D',
unit: 'day'
}
},
{
Expand Down Expand Up @@ -373,7 +380,11 @@ const options: ThisTypedComponentOptionsWithRecordProps<
},
type: 'time',
time: {
unit: 'month'
unit: 'month',
parser: 'M/D',
displayFormats: {
month: 'MMM'
}
}
}
],
Expand Down
2 changes: 1 addition & 1 deletion data/news.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
{
"date": "2020\/03\/25",
"url": "https:\/\/www.metro.tokyo.lg.jp\/tosei\/governor\/governor\/kishakaiken\/2020\/03\/25.html",
"text": "知事の記者会見(3月25日"
"text": "知事の記者会見(3月25日"
},
{
"date": "2020\/03\/25",
Expand Down
5 changes: 5 additions & 0 deletions nuxt.config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Configuration } from '@nuxt/types'
import { Configuration as WebpackConfiguration } from 'webpack'
import i18n from './nuxt-i18n.config'
const webpack = require('webpack')
const purgecss = require('@fullhuman/postcss-purgecss')
Expand Down Expand Up @@ -139,6 +140,10 @@ const config: Configuration = {
whitelistPatterns: [/(col|row)/]
})
]
},
extend(config: WebpackConfiguration, _) {
// default externals option is undefined
config.externals = [{ moment: 'moment' }]
}
// https://ja.nuxtjs.org/api/configuration-build/#hardsource
// hardSource: process.env.NODE_ENV === 'development'
Expand Down
79 changes: 79 additions & 0 deletions plugins/chartjs-adapter-dayjs.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
import { _adapters } from 'chart.js'
import dayjs from 'dayjs'
import customParseFormat from 'dayjs/plugin/customParseFormat'
import 'dayjs/locale/en'
import 'dayjs/locale/ja'
import 'dayjs/locale/ko'
import 'dayjs/locale/pt-br'
import 'dayjs/locale/th'
import 'dayjs/locale/vi'
import 'dayjs/locale/zh-cn'
import 'dayjs/locale/zh-tw'
import { NuxtAppOptions } from '@nuxt/types/app'

const DEFAULT_FORMATS = {
datetime: 'MMM D, YYYY, h:mm:ss a',
millisecond: 'h:mm:ss.SSS a',
second: 'h:mm:ss a',
minute: 'h:mm a',
hour: 'hA',
day: 'MMM D',
week: 'll',
month: 'MMM YYYY',
quarter: '[Q]Q - YYYY',
year: 'YYYY'
}

export function useDayjsAdapter(nuxtI18n: NuxtAppOptions['i18n']) {
dayjs.extend(customParseFormat)

// set locale when page onload
setLocale(nuxtI18n.locale)
nuxtI18n.onLanguageSwitched = (_: string, newLocale: string) => {
setLocale(newLocale)
}

_adapters._date.override({
_id: 'dayjs', // for debug

formats() {
return DEFAULT_FORMATS
},

parse(time, format) {
const value = format ? dayjs(time, format) : dayjs(time)

return value.isValid() ? value.valueOf() : null
},

format(time, format) {
return dayjs(time).format(format)
},

add(time, amount, unit) {
return dayjs(time).add(amount, unit)
},

diff(max, min, unit) {
return dayjs(max).diff(dayjs(min), unit)
},

startOf(time, unit, _) {
return dayjs(time).startOf(unit)
},

endOf(time, unit) {
return dayjs(time).endOf(unit)
}
})
}

function setLocale(newLocale: string) {
let locale = newLocale

if (locale.includes('ja')) {
locale = 'ja'
}

dayjs.locale(locale)
}
8 changes: 7 additions & 1 deletion plugins/vue-chart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import Vue, { PropType } from 'vue'
import { ChartData, ChartOptions } from 'chart.js'
import { Doughnut, Bar, Line, mixins } from 'vue-chartjs'
import { Plugin } from '@nuxt/types'
import { useDayjsAdapter } from './chartjs-adapter-dayjs'

type ChartVCData = { chartData: ChartData }
type ChartVCMethod = {
Expand All @@ -10,7 +11,12 @@ type ChartVCMethod = {
type ChartVCComputed = unknown
type ChartVCProps = { options: Object }

const VueChartPlugin: Plugin = () => {
const VueChartPlugin: Plugin = ({ app }) => {
useDayjsAdapter(app.i18n)
createCustomChart()
}

const createCustomChart = () => {
const { reactiveProp } = mixins

Vue.component<ChartVCData, ChartVCMethod, ChartVCComputed, ChartVCProps>(
Expand Down
43 changes: 43 additions & 0 deletions types/chart.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import { ConfigType, Dayjs, OpUnitType, QUnitType } from 'dayjs'

declare module 'chart.js' {
export class _adapters {
static _date: DayjsDateAdapter
}

interface DayjsDateAdapter {
override: (options: Options) => void
}

interface Options {
_id: string
formats: () => DateAdapterFormats
parse: (time: ConfigType, format: string | undefined) => number | null
format: (time: ConfigType, format: string) => string
add: (time: ConfigType, amount: number, unit: OpUnitType) => Dayjs
diff: (
max: ConfigType,
min: ConfigType,
unit: QUnitType | OpUnitType
) => number
startOf: (
time: ConfigType,
unit: OpUnitType,
weekday: null | undefined
) => Dayjs
endOf: (time: ConfigType, unit: OpUnitType) => Dayjs
}

export type DateAdapterFormats = {
datetime: string
millisecond: string
second: string
minute: string
hour: string
day: string
week: string
month: string
quarter: string
year: string
}
}
35 changes: 20 additions & 15 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1015,13 +1015,13 @@
wgs84 "0.0.0"

"@mapbox/geojson-rewind@^0.4.0":
version "0.4.0"
resolved "https://registry.yarnpkg.com/@mapbox/geojson-rewind/-/geojson-rewind-0.4.0.tgz#0d3632d4c1b4a928cf10a06ade387e1c8a8c181b"
integrity sha512-b+1uPWBERW4Pet/969BNu61ZPDyH2ilIxBjJDFzxyS9TyszF9UrTQyYIl/G38clux3rtpAGGFSGTCSF/qR6UjA==
version "0.4.1"
resolved "https://registry.yarnpkg.com/@mapbox/geojson-rewind/-/geojson-rewind-0.4.1.tgz#357d79300adb7fec7c1f091512988bca6458f068"
integrity sha512-mxo2MEr7izA1uOXcDsw99Kgg6xW3P4H2j4n1lmldsgviIelpssvP+jQDivFKOHrOVJDpTTi5oZJvRcHtU9Uufw==
dependencies:
"@mapbox/geojson-area" "0.2.2"
concat-stream "~1.6.0"
minimist "1.2.0"
minimist "^1.2.5"
sharkdown "^0.1.0"

"@mapbox/geojson-types@^1.0.2":
Expand Down Expand Up @@ -1873,9 +1873,9 @@
integrity sha512-dBp05MtWN/w1fGVjj5LVrDw6VrdYllpWczbUkCsrzBj08IHsSyRLOFvUrCFqZFVR+nsqkrRLNg6oOlvqMLPaSA==

"@types/mapbox-gl@^1.8.0":
version "1.8.0"
resolved "https://registry.yarnpkg.com/@types/mapbox-gl/-/mapbox-gl-1.8.0.tgz#b4df87a58f643500f8bc7b2807afbeb2ab114e07"
integrity sha512-XKgJRK8Z2gWRx2WeqQcBMaiplrgxnFgoE3IYQ7tf/cCMJ8iXJsMig2eTG0plo1H1yA09f47dPVwbBmoAVCcQHg==
version "1.8.1"
resolved "https://registry.yarnpkg.com/@types/mapbox-gl/-/mapbox-gl-1.8.1.tgz#dbc12da1324d5bdb3dbf71b90b77cac17994a1a3"
integrity sha512-DdT/YzpGiYITkj2cUwyqPilPbtZURr1E0vZX0KTyyeNP0t0bxNyKoXo0seAcvUd2MsMgFYwFQh1WRC3x2V0kKQ==
dependencies:
"@types/geojson" "*"

Expand Down Expand Up @@ -7615,9 +7615,9 @@ mapbox-gl-vue@^2.0.4:
integrity sha512-vJKoZh4tlvZnGxgJfWNjSjeKmzIKl2AFWXfRsEIt7Itb1efAGsMc9BzTb6C/nalel+z3cDVIpIo/Q8AmDPqC7w==

mapbox-gl@^1.8.1:
version "1.8.1"
resolved "https://registry.yarnpkg.com/mapbox-gl/-/mapbox-gl-1.8.1.tgz#83fd2e99274a226adbf1c01012c37d17fccdd4bc"
integrity sha512-Q6c8XAFxHxMPnZIfiRsExk5dNN+dCgvbRNHPfX7hHV5LDcX5Ptc1MEVpOJEDyojuriZssAeWMTJob0hir9mpUw==
version "1.9.0"
resolved "https://registry.yarnpkg.com/mapbox-gl/-/mapbox-gl-1.9.0.tgz#53e3e13c99483f362b07a8a763f2d61d580255a5"
integrity sha512-PKpoiB2pPUMrqFfBJpt/oA8On3zcp0adEoDS2YIC2RA6o4EZ9Sq2NPZocb64y7ra3mLUvEb7ps1pLVlPMh6y7w==
dependencies:
"@mapbox/geojson-rewind" "^0.4.0"
"@mapbox/geojson-types" "^1.0.2"
Expand Down Expand Up @@ -7870,16 +7870,21 @@ minimist@1.1.x:
resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.1.3.tgz#3bedfd91a92d39016fcfaa1c681e8faa1a1efda8"
integrity sha1-O+39kaktOQFvz6ocaB6Pqhoe/ag=

minimist@1.2.0, minimist@^1.1.1, minimist@^1.2.0:
version "1.2.0"
resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.0.tgz#a35008b20f41383eec1fb914f4cd5df79a264284"
integrity sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=

minimist@^0.1.0:
version "0.1.0"
resolved "https://registry.yarnpkg.com/minimist/-/minimist-0.1.0.tgz#99df657a52574c21c9057497df742790b2b4c0de"
integrity sha1-md9lelJXTCHJBXSX33QnkLK0wN4=

minimist@^1.1.1, minimist@^1.2.0:
version "1.2.0"
resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.0.tgz#a35008b20f41383eec1fb914f4cd5df79a264284"
integrity sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=

minimist@^1.2.5:
version "1.2.5"
resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.5.tgz#67d66014b66a6a8aaa0c083c5fd58df4e4e97602"
integrity sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==

minipass-collect@^1.0.2:
version "1.0.2"
resolved "https://registry.yarnpkg.com/minipass-collect/-/minipass-collect-1.0.2.tgz#22b813bf745dc6edba2576b940022ad6edc8c617"
Expand Down

0 comments on commit da68437

Please sign in to comment.