Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pkg/api/render.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ func HandleGetRender(browser *service.BrowserService) http.Handler {
var printerOpts []service.PNGPrinterOption
if height == -1 {
printerOpts = append(printerOpts, service.WithFullHeight(true))
options = append(options, service.WithViewport(width, 1080)) // add some height to make scrolling faster
options = append(options, service.WithViewport(width, int(float64(width)*0.75)))
}
options = append(options, service.WithPNGPrinter(printerOpts...))
default:
Expand Down
12 changes: 9 additions & 3 deletions pkg/service/browser.go
Original file line number Diff line number Diff line change
Expand Up @@ -840,7 +840,12 @@ func resizeViewportForFullHeight(opts *renderingOptions) chromedp.Action {
}

tracer := tracer(ctx)
ctx, span := tracer.Start(ctx, "resizeViewportForFullHeight")
ctx, span := tracer.Start(ctx, "resizeViewportForFullHeight",
trace.WithAttributes(
attribute.Int("currentViewportWidth", opts.viewportWidth),
attribute.Int("currentViewportHeight", opts.viewportHeight),
attribute.Bool("landscape", opts.landscape),
))
defer span.End()

var scrollHeight int
Expand All @@ -849,6 +854,7 @@ func resizeViewportForFullHeight(opts *renderingOptions) chromedp.Action {
span.SetStatus(codes.Error, "failed to get scroll height: "+err.Error())
return fmt.Errorf("failed to get scroll height: %w", err)
}
span.AddEvent("obtained scroll height", trace.WithAttributes(attribute.Int("scrollHeight", scrollHeight)))

// Only resize if the page is actually taller than the current viewport
if scrollHeight > opts.viewportHeight {
Expand All @@ -872,7 +878,7 @@ func resizeViewportForFullHeight(opts *renderingOptions) chromedp.Action {

span.SetStatus(codes.Ok, "viewport resized successfully")
} else {
span.AddEvent("no viewport resize needed", trace.WithAttributes(attribute.Int("pageHeight", scrollHeight)))
span.AddEvent("no viewport resize needed")
}

return nil
Expand Down Expand Up @@ -964,7 +970,7 @@ func waitForReady(browserCtx context.Context, timeout time.Duration) chromedp.Ac
timeout := time.After(timeout)

hasHadQueries := false
giveUpFirstQuery := time.Now().Add(time.Second * 3)
giveUpFirstQuery := time.Now().Add(time.Second * 1)

var domHashCode int
initialDOMPass := true
Expand Down
230 changes: 230 additions & 0 deletions tests/acceptance/fixtures/dashboards/bar-chart-panels.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,230 @@
{
"annotations": {
"list": [
{
"builtIn": 1,
"datasource": {
"type": "grafana",
"uid": "-- Grafana --"
},
"enable": true,
"hide": true,
"iconColor": "rgba(0, 211, 255, 1)",
"name": "Annotations & Alerts",
"type": "dashboard"
}
]
},
"editable": true,
"fiscalYearStartMonth": 0,
"graphTooltip": 0,
"id": 9,
"links": [],
"panels": [
{
"datasource": {
"type": "grafana-testdata-datasource",
"uid": "testdata"
},
"fieldConfig": {
"defaults": {
"color": {
"mode": "palette-classic"
},
"custom": {
"axisBorderShow": false,
"axisCenteredZero": false,
"axisColorMode": "text",
"axisLabel": "",
"axisPlacement": "auto",
"fillOpacity": 80,
"gradientMode": "none",
"hideFrom": {
"legend": false,
"tooltip": false,
"viz": false
},
"lineWidth": 1,
"scaleDistribution": {
"type": "linear"
},
"thresholdsStyle": {
"mode": "off"
}
},
"mappings": [],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "red",
"value": 0
},
{
"color": "green",
"value": 0
}
]
}
},
"overrides": []
},
"gridPos": {
"h": 8,
"w": 12,
"x": 0,
"y": 0
},
"id": 1,
"options": {
"barRadius": 0,
"barWidth": 0.97,
"fullHighlight": false,
"groupWidth": 0.7,
"legend": {
"calcs": [],
"displayMode": "list",
"placement": "bottom",
"showLegend": true
},
"orientation": "auto",
"showValue": "auto",
"stacking": "none",
"tooltip": {
"hideZeros": false,
"mode": "single",
"sort": "none"
},
"xTickLabelRotation": 0,
"xTickLabelSpacing": 0
},
"pluginVersion": "12.3.0-17962464148",
"targets": [
{
"csvContent": "Title,Value\na,0.5\nb,1.0\nc,-1",
"datasource": {
"type": "grafana-testdata-datasource",
"uid": "testdata"
},
"refId": "A",
"scenarioId": "csv_content"
}
],
"title": "Default Bar chart",
"type": "barchart"
},
{
"datasource": {
"type": "grafana-testdata-datasource",
"uid": "testdata"
},
"fieldConfig": {
"defaults": {
"color": {
"mode": "palette-classic"
},
"custom": {
"axisBorderShow": false,
"axisCenteredZero": false,
"axisColorMode": "text",
"axisLabel": "",
"axisPlacement": "auto",
"fillOpacity": 50,
"gradientMode": "hue",
"hideFrom": {
"legend": false,
"tooltip": false,
"viz": false
},
"lineWidth": 1,
"scaleDistribution": {
"type": "linear"
},
"thresholdsStyle": {
"mode": "dashed+area"
}
},
"mappings": [],
"max": 5,
"min": -1.5,
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "red",
"value": 0
},
{
"color": "green",
"value": 0
}
]
},
"unit": "lengthmm"
},
"overrides": []
},
"gridPos": {
"h": 8,
"w": 12,
"x": 12,
"y": 0
},
"id": 2,
"options": {
"barRadius": 0.1,
"barWidth": 0.82,
"colorByField": "Value",
"fullHighlight": false,
"groupWidth": 0.7,
"legend": {
"calcs": [],
"displayMode": "list",
"placement": "bottom",
"showLegend": true
},
"orientation": "auto",
"showValue": "auto",
"stacking": "none",
"tooltip": {
"hideZeros": false,
"mode": "multi",
"sort": "none"
},
"xTickLabelRotation": 0,
"xTickLabelSpacing": 0
},
"pluginVersion": "12.3.0-17962464148",
"targets": [
{
"csvContent": "Title,Value\na,0.5\nb,1.0\nc,-1",
"datasource": {
"type": "grafana-testdata-datasource",
"uid": "testdata"
},
"refId": "A",
"scenarioId": "csv_content"
}
],
"title": "Bar chart with unit, min, max, and fill",
"type": "barchart"
}
],
"preload": false,
"schemaVersion": 42,
"tags": [
"barchart"
],
"templating": {
"list": []
},
"time": {
"from": "now-6h",
"to": "now"
},
"timepicker": {},
"timezone": "browser",
"title": "Bar chart panels",
"uid": "bar-charts",
"version": 1
}
Loading
Loading