psrc / psrcplot

Package for Creating PSRC consistent data visualizations with R
https://psrc.github.io/psrcplot/
GNU General Public License v3.0
2 stars 0 forks source link

Interactive line chart tooltip #71

Closed MrichardsPSRC closed 1 year ago

MrichardsPSRC commented 1 year ago

I'm attemmpting to create an interactive line chart and the hovering tool tip is duplicated?

image

# creating interactive line chart
line_option <- interactive_line_chart(t=lifeexpec_poc_trend,
                                      x="year", y="health_ind",
                                      fill="quintile_order",
                                      est = "number",
                                      color = "blues_inc",
                                      dform = "%Y",
                                      title = indicator_measure,
                                      subtitle = "People of Color",
                                      source = paste("Sources: Washington Tracking Network, Washington State Department of Health,", "\n", "U.S. Census Bureau, ACS 1-year, 2015-2020,", "\n", "2020 Census Tracts"))

line_option
MrichardsPSRC commented 1 year ago

Issue seems to be resolved by using a date type year field, instead of the numeric year field

image

# need to make the year column date format
lifeexpec_poc_trend$year_date <- as.Date((as.character(lifeexpec_poc_trend$year)),
                                         format = "%Y")

# creating interactive line chart
line_option <- interactive_line_chart(t=lifeexpec_poc_trend,
                                      x="year_date", y="health_ind",
                                      fill="quintile_order",
                                      est = "number",
                                      color = "blues_inc",
                                      dform = "%Y",
                                      title = indicator_measure,
                                      subtitle = "People of Color",
                                      source = paste("Sources: Washington Tracking Network, Washington State Department of Health,", "\n", "U.S. Census Bureau, ACS 1-year, 2015-2020,", "\n", "2020 Census Tracts"))

line_option