highcharter with multiples in r

I am doing a visualisation on health data set available here

By using this code i

df1 <- xts(df[,-1], order.by=as.Date(df$date))
#highchart() %>%
highcharter::highchart(type = "stock") %>% 
  hc_yAxis_multiples(
    list(title = list(text = "Volume ")),
    list(title = list(text = "value "),
         opposite = FALSE)
  ) %>%
  hc_add_series(data = df1$Volume,
                name = "Volume ",
                type = "line",
                color = "#e3972f",
                yAxis = 0) %>%
  hc_add_series(data = df1$Amount,
                name = "value ",
                type = "line",
                color = "#0b539d",
                yAxis = 1) %>%
  hc_xAxis(categories = df1$date, 
  plotBands = list(
    list(
      label = list(text = "Lockdown"),
      color = "rgba(100, 0, 0, 0.1)",
      from = datetime_to_timestamp(as.Date('2020-03-31', tz = 'UTC')),
      to = datetime_to_timestamp(as.Date(Sys.Date(), tz = 'UTC'))
    )
  )) %>%
  #hc_colors(cols) %>%
  hc_chart(style = list(fontFamily = "Georgia",
                        fontWeight = "bold"))%>%
 hc_scrollbar(enabled = FALSE) %>%
  #hc_add_theme(hc_theme_gridlight()) %>%
  hc_exporting(enabled = TRUE)%>%
  highcharter::hc_legend(enabled = TRUE)

I m getting this out plot.

But when you check on these two line they like the same, which is wrong. Can someone help me to check the error in my code please?

Hi @dniyitanga,
The variables Amount and Volume are tracking each other pretty closely, as shown in these simple base-R graphs. So, maybe highcharter is working exactly as expected?

a <- "
num date	Volume	Amount
1	2020-01-01	11647	147601737
2	2020-01-02	18287	313540352
3	2020-01-03	21175	388407199
4	2020-01-06	60139	919092129
5	2020-01-07	17120	355846527
6	2020-01-08	17354	344375795
7	2020-01-09	18256	329638363
8	2020-01-10	16040	336812332
9	2020-01-13	38011	711856248
10	2020-01-14	17644	331176918
11	2020-01-15	18912	360334999
12	2020-01-16	18607	346921286
13	2020-01-17	17223	310318381
14	2020-01-20	42870	687256914
15	2020-01-21	16495	300547127
16	2020-01-22	19049	334119997
17	2020-01-23	22126	388066684
18	2020-01-24	24604	427844685
19	2020-01-27	57795	986992949
20	2020-01-28	35147	640823320
21	2020-01-29	36565	713641001
22	2020-01-30	42107	749452393
23	2020-01-31	38605	655324978
24	2020-02-03	54791	845733091
25	2020-02-04	25957	390337795
26	2020-02-05	29994	452437848
27	2020-02-06	18965	370559705
28	2020-02-07	18788	384271389
29	2020-02-10	45022	840661521
30	2020-02-11	19866	416796260
31	2020-02-12	19338	373698971
32	2020-02-13	19481	344900121
33	2020-02-14	20142	344886773
34	2020-02-17	47807	780248844
35	2020-02-18	17997	276425567
36	2020-02-19	17999	255100805
37	2020-02-20	19021	274558928
38	2020-02-21	19647	306218087
39	2020-02-24	44334	581960846
40	2020-02-25	24569	368563304
41	2020-02-26	26313	393863379
42	2020-02-27	30617	477262810
43	2020-02-28	38866	675203501
44	2020-03-02	64516	1038127202
45	2020-03-03	26093	445076584
46	2020-03-04	26293	355241633
47	2020-03-05	29743	383192245
48	2020-03-06	18897	329155213
49	2020-03-09	42726	621158943
50	2020-03-10	16587	280750025
51	2020-03-11	16198	266043186
52	2020-03-12	14492	231557693
53	2020-03-13	12695	233425804
54	2020-03-16	47233	718210004
55	2020-03-17	16192	220383943
56	2020-03-18	15887	242760483
57	2020-03-19	15888	268108939
58	2020-03-20	13903	254942839
59	2020-03-23	47137	730712196
60	2020-03-24	20916	290744382
61	2020-03-25	23330	382871412
62	2020-03-26	21398	371269493
63	2020-03-27	18301	338107615
64	2020-03-30	55663	901989718
65	2020-03-31	15021	276140508
66	2020-04-01	19808	396463092
67	2020-04-02	17212	371800366
68	2020-04-03	16454	347761306
69	2020-04-06	44731	733181649
70	2020-04-08	26341	425264566
71	2020-04-09	14481	258363406
72	2020-04-13	49768	784355681
73	2020-04-14	15040	313996978
74	2020-04-15	16906	367172546
75	2020-04-16	14893	270182703
76	2020-04-17	14100	287082241
77	2020-04-20	40458	625298525
"

df <- read.table(text=a, header=TRUE)
head(df)

plot(Volume ~ as.Date(date), data=df, type="b")
plot(Amount ~ as.Date(date), data=df, type="b")
plot(Volume ~ Amount, data=df) 

BTW, thanks for showing us the great interactive graphics in highcharter!
HTH

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.