Skip to content

Commit b1ba5bc

Browse files
committed
Merge branch 'timeline-slider' into ms-2-part-2
2 parents dc36022 + 2e3a141 commit b1ba5bc

File tree

6 files changed

+233
-87
lines changed

6 files changed

+233
-87
lines changed

components/DatePicker.vue

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,8 @@ const updateSelectedRange = (from, to) => {
122122
} else {
123123
selectedRange.value = `${from.toFormat("dd LLL yyyy")} - ${to.toFormat("dd LLL yyyy")}`
124124
}
125+
month.value = to.c.month
126+
year.value = to.c.year
125127
} else {
126128
selectedRange.value = from.toFormat("dd LLL")
127129
}
@@ -131,8 +133,8 @@ const updateSelectedRange = (from, to) => {
131133
}
132134
updateSelectedRange(startDate.value, endDate.value)
133135
134-
const isNextMonthAvailable = true // computed(() => !(month.value === currentDate.value.month && year.value === currentDate.value.year))
135-
const isPrevMonthAvailable = true // computed(() => limitMinDate.value ? limitMinDate.value.ts < days.value[0][0].ts : true)
136+
const isNextMonthAvailable = true
137+
const isPrevMonthAvailable = true
136138
const isDayAvailable = (d) => {
137139
if (d.startOf("day").ts > currentDate.value.startOf("day").ts) {
138140
return false
@@ -154,6 +156,8 @@ const handleSelectPeriod = (period) => {
154156
startDate.value = DateTime.now()
155157
.minus({
156158
days: period.timeframe === "day" ? period.value - 1 : 0,
159+
months: period.timeframe === "month" ? period.value : 0,
160+
years: period.timeframe === "year" ? period.value : 0,
157161
})
158162
.startOf("day")
159163
endDate.value = DateTime.now().endOf("day")
@@ -193,6 +197,12 @@ const isInSelectedPeriod = (d) => {
193197
194198
const isOpen = ref(false)
195199
const handleOpen = () => {
200+
if (props.to) {
201+
let to = DateTime.fromSeconds(parseInt(props.to))
202+
month.value = to.c.month
203+
year.value = to.c.year
204+
}
205+
196206
isOpen.value = true
197207
}
198208
const handleClose = () => {

components/modules/stats/BarChart.vue

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,10 @@ const buildChart = (chart, cData, onEnter, onLeave) => {
5757
const y = d3.scaleLinear([MIN_VALUE, MAX_VALUE], [height - marginBottom, marginTop])
5858
5959
function formatDate(date) {
60+
if (props.series?.timeframe?.timeframe === "hour") {
61+
return DateTime.fromJSDate(date).toFormat("HH:mm, LLL dd, yyyy")
62+
}
63+
6064
return DateTime.fromJSDate(date).toFormat("LLL dd, yyyy")
6165
}
6266
@@ -105,7 +109,12 @@ const buildChart = (chart, cData, onEnter, onLeave) => {
105109
svg.append("g")
106110
.attr("transform", `translate(0, ${height - marginAxisX})`)
107111
.attr("color", "var(--op-20)")
108-
.call(d3.axisBottom(scaleX).ticks(Math.min(cData.data.length, 6)).tickFormat(d3.timeFormat("%b %d")))
112+
.call(
113+
d3
114+
.axisBottom(scaleX)
115+
.ticks(Math.min(cData.data.length, 6))
116+
.tickFormat(d3.timeFormat(["hour", "day"].includes(props.series.timeframe.timeframe) ? "%b %d" : "%b"))
117+
)
109118
.selectAll(".tick line")
110119
.filter(function (d) {
111120
return d === 0

components/modules/stats/LineChart.vue

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ const buildChart = (chart, cData, onEnter, onLeave) => {
4949
.curve(d3.curveCatmullRom)
5050
5151
function formatDate(date) {
52-
if (props.series.timeframe === "hour") {
53-
return DateTime.fromJSDate(date).toFormat("LLL dd, HH:mm")
52+
if (props.series?.timeframe?.timeframe === "hour") {
53+
return DateTime.fromJSDate(date).toFormat("HH:mm, LLL dd, yyyy")
5454
}
5555
5656
return DateTime.fromJSDate(date).toFormat("LLL dd, yyyy")
@@ -104,8 +104,8 @@ const buildChart = (chart, cData, onEnter, onLeave) => {
104104
.call(
105105
d3
106106
.axisBottom(x)
107-
.ticks(6)
108-
.tickFormat(d3.timeFormat(props.series.timeframe === "hour" ? "%H:%M" : "%b %d")),
107+
.ticks(Math.min(cData.data.length, 6))
108+
.tickFormat(d3.timeFormat(["hour", "day"].includes(props.series.timeframe.timeframe) ? "%b %d" : "%b"))
109109
)
110110
111111
svg.append("g")

0 commit comments

Comments
 (0)