我正在使用 highcharter 绘制烛台图。我需要向图表添加多个注释,其数据在单独的数据框中可用。
我尝试的代码根本不打印注释。如果我将代码更改为只打印一个注释,它就可以工作。
关于如何绘制多个注释的任何建议。另外,我需要这些注释在点的左下角带有一个箭头。对此也有建议
library(highcharter)
df <- structure(c(1260.05, 1288.45, 1269, 1263.3, 1282.25, 1319.2,
1335, 1328.5, 1324.8, 1329.5, 1356.9, 1373, 1370, 1386.05, 1392.25,
1393.75, 1330, 1350.1, 1372.45, 1357.85, 1346.75, 1344.7, 1346.9,
1382, 1380, 1391, 1423, 1410.25, 1430, 1455, 1276.6, 1299.75,
1274.3, 1284.5, 1310, 1347, 1363.85, 1340, 1346.1, 1350.45, 1374,
1391.7, 1379.9, 1406, 1400, 1393.75, 1355.2, 1376, 1383.25, 1370.45,
1352.5, 1356.7, 1400, 1388, 1391.6, 1425, 1426, 1434.95, 1451.7,
1455, 1252, 1272, 1244.75, 1259, 1279.2, 1308, 1325.9, 1305.05,
1317.2, 1318.75, 1355, 1370.05, 1358.5, 1380.5, 1382, 1313.5,
1318, 1336.1, 1359.6, 1346.25, 1327.6, 1332, 1336.15, 1363.3,
1371, 1387, 1406.45, 1406.6, 1421, 1430.05, 1272.7, 1275, 1252,
1271, 1308.6, 1340.95, 1334.6, 1320.05, 1336.05, 1344, 1366.5,
1375.3, 1371.95, 1384.6, 1387.1, 1341.8, 1347.15, 1371.1, 1369.8,
1355, 1337.6, 1338.7, 1386.5, 1367.3, 1386, 1415, 1414, 1430,
1438.15, 1441.05, 4537258, 8788221, 15132388, 5756286, 10461434,
9056399, 12041941, 6486176, 5119392, 6518173, 7925984, 9462061,
6658665, 9352771, 7626744, 10961755, 12767112, 4862758, 7165335,
6134303, 8749994, 4922071, 10546919, 8220987, 5675155, 9479572,
5793571, 5879234, 5654434, 6050771), Symbol = "INFY", class = c("xts",
"zoo"), index = structure(c(1614124800, 1614211200, 1614297600,
1614556800, 1614643200, 1614729600, 1614816000, 1614902400, 1615161600,
1615248000, 1615334400, 1615507200, 1615766400, 1615852800, 1615939200,
1616025600, 1616112000, 1616371200, 1616457600, 1616544000, 1616630400,
1616716800, 1617062400, 1617148800, 1617235200, 1617580800, 1617667200,
1617753600, 1617840000, 1617926400), tzone = "UTC", tclass = "Date"), .Dim = c(30L,
5L), .Dimnames = list(NULL, c("Open", "High", "Low", "Close",
"Volume")))
dfSignals <- structure(list(Date = structure(c(18701, 18704, 18711), class = "Date"),
Low = c(1358.5, 1313.5, 1327.6)), class = "data.frame", row.names = c(3L,
6L, 11L))
highchart(type = "stock") %>%
hc_add_series(data = df,
name = "OHLC",
type = "candlestick") %>%
hc_colors(color = "red") %>%
hc_rangeSelector(selected = 0) %>%
hc_annotations(
list(
labelOptions = list(y = 50, x = 0),
labels = list(
list(
point = list(
#xValue =head(tail(dfSignals,2),1)$Date,
xAxis = 0,
yAxis = 0,
x=(highcharter::datetime_to_timestamp(dfSignals$Date)),
y = dfSignals$Low,
anchorX="left",
anchorY="bottom",
xAxis = 0,
yAxis = 0
),
text="A"
)
)
)
)