Skip to content

Commit 5c90a9c

Browse files
dmigwichappjc
authored andcommitted
Charts: Dual x-axis support for all historical charts
All historical charts have a button that enables switching between the twox-axis types namely: Block Height and Block Time. A group button at the chart bottom was added to enable easy swapping of either of the two x-axis. Since dygraph doesn't support display of multiple x-axis the two distinct x-axes cannot not be displayed together. No changes to the data stored in charts cache was made to enable an extra x-axis to be swapped on a chart with the same y-axis data set. The query below allows the index of each record retrieved to be used like a Block Height since the query is ordered by height. Therefore no extra data is required when the bin value is set to blocks. SelectBlockStats = `SELECT height, size, time, chainwork, numtx FROM blocks WHERE is_mainchain AND height > $1 ORDER BY height;` When the bin value is set to day, a pre-populated height array entry existed. * Add the UI axis selector buttons stimulusjs controls * Add height axis to all historical charts * Fix ticket price and pow difficulty height x-axis values * Fix the coins supply chart * Rename zoom variables to bin * Keep support for the deprecated zoom parameter * Delete redundant zoom_helper implementations * Fix the broken slider zoom selector feature * Optimize the mapKey for legacy URLs and slider zoom features
1 parent 2deca47 commit 5c90a9c

File tree

8 files changed

+455
-307
lines changed

8 files changed

+455
-307
lines changed

api/apiroutes.go

+8-3
Original file line numberDiff line numberDiff line change
@@ -1602,11 +1602,16 @@ func (c *appContext) getAddressTxAmountFlowData(w http.ResponseWriter, r *http.R
16021602

16031603
func (c *appContext) ChartTypeData(w http.ResponseWriter, r *http.Request) {
16041604
chartType := m.GetChartTypeCtx(r)
1605-
zoom := r.URL.Query().Get("zoom")
1606-
chartData, err := c.charts.Chart(chartType, zoom)
1605+
bin := r.URL.Query().Get("bin")
1606+
// Support the deprecated URL parameter "zoom".
1607+
if bin == "" {
1608+
bin = r.URL.Query().Get("zoom")
1609+
}
1610+
axis := r.URL.Query().Get("axis")
1611+
chartData, err := c.charts.Chart(chartType, bin, axis)
16071612
if err != nil {
16081613
http.NotFound(w, r)
1609-
log.Warnf(`Error fetching chart %s at zoom level '%s': %v`, chartType, zoom, err)
1614+
log.Warnf(`Error fetching chart %s at bin level '%s': %v`, chartType, bin, err)
16101615
return
16111616
}
16121617
writeJSONBytes(w, chartData)

0 commit comments

Comments
 (0)