Candlestick panel in "Both" mode

Hi, dear Grafana community!

  • What Grafana version and what operating system are you using?
    I’m using Grafana Version 9.3.1 (commit: 89b365f8b1, branch: HEAD) installed in Windows 10 WSL:
    5.10.102.1-microsoft-standard-WSL2 #1 SMP Wed Mar 2 00:30:59 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux

  • What are you trying to achieve?
    I’m trying to use candlestick panel in “Both” mode with simultaneous OHLC and Volume bars.

  • How are you trying to achieve it?
    I’m using query to ClickHouse DB directly selecting DateTime and OHLC+Volume fields.

  • What happened?
    OHLC and Volume are shown on the panel, but both of them have a very low scale (both graphs occupy about 1/5 lower part of the working filed, the rest upper part of the field is empty) and have the same zero level and intersect with each others. Possibly, there is an error in calculating upper bound of the Y-axis in “Both” mode. In separate “Candles” and “Volume” modes scale is correct.

  • What did you expect to happen?
    I expected to see a much higher usage of Y-axis in “Both” mode of candlestick panel.

  • Can you copy/paste the configuration(s) that you are having problems with?

{
  "id": 2,
  "gridPos": {
    "h": 13,
    "w": 12,
    "x": 0,
    "y": 0
  },
  "type": "candlestick",
  "title": "Panel Title",
  "transformations": [],
  "datasource": {
    "uid": "xE1jQZc4k",
    "type": "vertamedia-clickhouse-datasource"
  },
  "maxDataPoints": 500,
  "fieldConfig": {
    "defaults": {
      "custom": {
        "drawStyle": "line",
        "lineInterpolation": "linear",
        "barAlignment": 0,
        "lineWidth": 1,
        "fillOpacity": 49,
        "gradientMode": "none",
        "spanNulls": false,
        "showPoints": "auto",
        "pointSize": 4,
        "stacking": {
          "mode": "none",
          "group": "A"
        },
        "axisPlacement": "auto",
        "axisLabel": "",
        "axisColorMode": "series",
        "scaleDistribution": {
          "type": "linear"
        },
        "axisCenteredZero": false,
        "hideFrom": {
          "tooltip": false,
          "viz": false,
          "legend": false
        },
        "thresholdsStyle": {
          "mode": "line"
        },
        "lineStyle": {
          "fill": "solid"
        }
      },
      "color": {
        "mode": "palette-classic"
      },
      "mappings": [],
      "thresholds": {
        "mode": "absolute",
        "steps": [
          {
            "color": "green",
            "value": null
          }
        ]
      },
      "unit": "none"
    },
    "overrides": []
  },
  "options": {
    "mode": "candles+volume",
    "candleStyle": "candles",
    "colorStrategy": "open-close",
    "colors": {
      "up": "green",
      "down": "red"
    },
    "includeAllFields": false,
    "legend": {
      "showLegend": false,
      "displayMode": "list",
      "placement": "bottom",
      "calcs": []
    },
    "fields": {
      "close": "pclose",
      "high": "pmax",
      "low": "pmin",
      "open": "popen",
      "volume": "volume"
    }
  },
  "targets": [
    {
      "database": "default",
      "datasource": {
        "type": "vertamedia-clickhouse-datasource",
        "uid": "xE1jQZc4k"
      },
      "dateColDataType": "",
      "dateLoading": false,
      "dateTimeColDataType": "time_stamp",
      "dateTimeType": "DATETIME",
      "datetimeLoading": false,
      "extrapolate": false,
      "format": "time_series",
      "formattedQuery": "SELECT $timeSeries as t, count() FROM $table WHERE $timeFilter GROUP BY t ORDER BY t",
      "hide": false,
      "interval": "",
      "intervalFactor": 1,
      "query": "SELECT\n    time_stamp,\n    popen,\n    pclose,\n    pmin,\n    pmax,\n    volume\nFROM rates_test\n\nWHERE asset = 'Dash'\n  AND $timeFilter\n\nORDER BY time_stamp\n",
      "rawQuery": "SELECT\n    time_stamp,\n    popen,\n    pclose,\n    pmin,\n    pmax,\n    volume\nFROM rates_test\n\nWHERE asset = 'Dash'\n  AND time_stamp >= toDateTime(1609404857) AND time_stamp <= toDateTime(1614838381)\n\nORDER BY time_stamp",
      "refId": "A",
      "round": "0s",
      "skip_comments": true,
      "table": "rates_test",
      "tableLoading": false
    }
  ],
  "interval": null
}

Welcome

On the right side of your dashboard, you should find min,max settings. You can search min or max in the search box of panel config. Maybe it has a default setting you can change there

But also notice your right and left y axis. One is low 5 digit , right one is billions?

1 Like

Hi yosiasz!
That’s correct, candles on the hundreds level and volume on billions. But changing billions to thousands and using “Max” option didn’t solved the problem. In “Both” mode Y-axis control options not working (see screenshot below).

Ok could you please provide some sample data as csv inline

High,low,start,end,date 

Forgot ehat the key data points needed are

yosiasz, sure, it was one file of free historical top-100 cryptocurrencies set. Part of one file (Dash):

Date,Open,High,Low,Close,Volume,Currency
2017-11-09,315.47698974609375,337.22601318359375,311.8190002441406,326.00799560546875,110840000.0,USD
2017-11-10,325.2659912109375,353.3580017089844,308.4590148925781,329.5710144042969,116352000.0,USD
2017-11-11,331.4280090332031,349.0799865722656,321.0409851074219,346.0559997558594,88651000.0,USD
2017-11-12,345.67999267578125,536.1160278320312,327.79901123046875,536.1160278320312,476198016.0,USD
2017-11-13,507.04901123046875,530.9409790039062,403.5010070800781,427.37298583984375,310886016.0,USD
2017-11-14,428.30999755859375,447.9219970703125,408.9549865722656,427.5409851074219,123854000.0,USD
2017-11-15,428.0799865722656,444.3819885253906,418.47198486328125,424.4129943847656,103157000.0,USD
2017-11-16,424.50799560546875,427.8479919433594,412.83599853515625,418.1820068359375,97321296.0,USD
2017-11-17,420.5889892578125,436.0159912109375,412.4530029296875,424.9830017089844,95099296.0,USD
2017-11-18,424.35101318359375,483.09698486328125,423.2449951171875,454.74200439453125,145255008.0,USD
2017-11-19,455.3590087890625,455.6600036621094,431.7919921875,442.3110046386719,82954600.0,USD
2017-11-20,442.0260009765625,502.531005859375,438.4200134277344,486.5350036621094,104701000.0,USD
2017-11-21,500.2380065917969,519.4180297851562,454.4840087890625,494.2130126953125,245163008.0,USD
2017-11-22,494.7619934082031,594.5289916992188,494.29400634765625,578.8460083007812,381958016.0,USD
2017-11-23,577.2509765625,583.7329711914062,557.1220092773438,566.6790161132812,173698000.0,USD
2017-11-24,564.3369750976562,573.1950073242188,553.5750122070312,566.635009765625,129105000.0,USD
2017-11-25,566.9559936523438,656.135009765625,566.9559936523438,643.572021484375,242807008.0,USD
2017-11-26,641.4569702148438,646.2830200195312,617.739013671875,621.6229858398438,145500000.0,USD
2017-11-27,621.14697265625,638.948974609375,611.7899780273438,632.2960205078125,134862000.0,USD
2017-11-28,632.4439697265625,637.0560302734375,616.3079833984375,626.4210205078125,149795008.0,USD
2017-11-29,626.2620239257812,815.0079956054688,625.364990234375,677.39501953125,415879008.0,USD
2017-11-30,681.1270141601562,826.9500122070312,670.9879760742188,786.9290161132812,498872000.0,USD
2017-12-01,787.469970703125,806.3720092773438,756.4840087890625,797.531005859375,286044000.0,USD
2017-12-02,797.9019775390625,802.1209716796875,769.385986328125,778.4340209960938,188147008.0,USD
2017-12-03,778.781005859375,806.7000122070312,744.3920288085938,768.8759765625,192447008.0,USD
2017-12-04,770.5689697265625,778.051025390625,738.593017578125,774.0130004882812,152280992.0,USD
2017-12-05,774.7069702148438,779.9819946289062,754.27197265625,756.3590087890625,201103008.0,USD
2017-12-06,756.010009765625,785.1829833984375,692.0189819335938,700.072998046875,249072992.0,USD
2017-12-07,699.9849853515625,714.5059814453125,667.8289794921875,697.9010009765625,249304992.0,USD
2017-12-08,700.6840209960938,766.0380249023438,659.8569946289062,726.6680297851562,288291008.0,USD
2017-12-09,727.6380004882812,774.6510009765625,707.3209838867188,723.6119995117188,211738000.0,USD
2017-12-10,723.2329711914062,723.8289794921875,645.1640014648438,688.666015625,190183008.0,USD
2017-12-11,688.5490112304688,768.9349975585938,688.155029296875,765.39697265625,184131008.0,USD
2017-12-12,765.9639892578125,948.6480102539062,746.93701171875,932.0349731445312,370539008.0,USD
2017-12-13,925.0170288085938,931.2109985351562,810.9630126953125,886.885009765625,268426000.0,USD
2017-12-14,884.2130126953125,968.4719848632812,866.635009765625,941.10498046875,259303008.0,USD
2017-12-15,943.3179931640625,947.2849731445312,850.6279907226562,900.5180053710938,191527008.0,USD
2017-12-16,901.2210083007812,1001.510009765625,897.2880249023438,1001.510009765625,195788000.0,USD
2017-12-17,1014.510009765625,1178.1800537109375,1014.510009765625,1105.9200439453125,460593984.0,USD
2017-12-18,1110.1600341796875,1195.739990234375,1044.760009765625,1167.1199951171875,278638016.0,USD
2017-12-19,1165.030029296875,1254.280029296875,1126.8499755859375,1186.6300048828125,302868992.0,USD
2017-12-20,1184.9200439453125,1642.219970703125,1167.300048828125,1550.8499755859375,816872000.0,USD
2017-12-21,1555.5899658203125,1622.260009765625,1371.3900146484375,1434.8199462890625,476900000.0,USD
2017-12-22,1441.9000244140625,1452.449951171875,864.3709716796875,1179.010009765625,510588000.0,USD

If you are going to use clickhouse for your tests, you can use this SQL script to create a table:

CREATE TABLE default.rates_test
(
	asset 		LowCardinality(String) NOT NULL,
	buy_for		LowCardinality(String) NOT NULL,
	for_period	LowCardinality(String) NOT NULL,
	time_stamp	DateTime('UTC') NOT NULL,
	volume		Decimal64(2),
	popen		Decimal128(16),
	pclose		Decimal128(16),
	pmin		Decimal128(16),
	pmax		Decimal128(16)
)
ENGINE = Memory
;

And you can use this shell-script to load a file (or all files from the set) into a table (for local clickhouse, run it in directory with CSV file(s)):

for i in *.csv 
do
  echo "Loading file $i as currency ${i%.*}"
  clickhouse-client --user default --password default --query "INSERT INTO rates_test SELECT '${i%.*}', Currency, 'day', toDateTime(Date, 'UTC'), Volume, Open, Close, Low,  High FROM input ('Date String, Open decimal128(16), High decimal128(16), Low decimal128(16), Close decimal128(16), Volume Decimal64(2), Currency String') FORMAT CSVWithNames" < "$i"
done
1 Like

What version of grafana are you on?

1 Like

yosiasz, as I wrote before, I’m using
Version 9.3.1 (commit: 89b365f8b1, branch: HEAD)
UPD: could you please post here your version?

1 Like

9.2.3 not wsl but straight on windows

1 Like

yosiasz, I finally find out the reason of such Grafana behavior. There are two plugins in Grafana for ClickHouse database: native plugin from Grafana Labs and Altinity plugin from Vertamedia. I choose the wrong one (Altinity) and it caused the issue. I switched to native plugin and the graph became just like on your screenshot.
Thanks a lot for your help!

UPD: one additional and important update - native Grafana Clickhouse plugin works only in HTTP mode. Native mode didn’t started.

1 Like