You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am trying to create a line chart over a bar chart without displaying an actual line like in the image below. However despite specifying chart_data_line_style('none') in the code, the line still shows up. Here is the code with the reproducible R example with sample iris data and the way I am currently implementing ms_linchart(). :
IMHO this is a bug. But as long as you want to remove the lines for all series you can achieve that by setting the style of the linchart to "marker" using chart_settings().
Using a minimized reprex based on mtcars:
library(officer)
library(mschart)
diamondLineWrapper <- function(data, x, y, group) {
chart <- ms_linechart(data = data, x = x, y = y, group = group)
chart_settings(chart, style = "marker")
}
diamond_chart <- mtcars |>
transform(cyl = factor(cyl)) |>
diamondLineWrapper(x = "hp", y = "mpg", group = "cyl")
doc <- read_pptx()
doc <- add_slide(doc, layout = "Title and Content", master = "Office Theme")
doc <- ph_with(doc, value = diamond_chart, location = ph_location_fullsize())
print(doc, target = "example.pptx")
Hi mschart community,
I am trying to create a line chart over a bar chart without displaying an actual line like in the image below. However despite specifying chart_data_line_style('none') in the code, the line still shows up. Here is the code with the reproducible R example with sample iris data and the way I am currently implementing ms_linchart(). :
library(officer)
library(mschart)
library(reshape)
library(dplyr)
diamondLineWrapper <- function(data, x, y, group){
print("diamondLineWrapper")
data_text_style <- fp_text(font.size = 12, bold = F, color = "#5a5a5a" )
g <- ms_linechart(data = data, x = x, y = y, group = group) %>%
chart_settings( grouping = "standard") %>%
chart_data_fill( "#002c77") %>%
chart_ax_x(display=1,cross_between = "midCat",major_tick_mark = "none",minor_tick_mark = "none", rotation = -30) %>%
chart_ax_y(display=1, major_tick_mark = "none", minor_tick_mark = "none", rotation = 0) %>%
chart_data_labels(show_val = F) %>%
chart_labels(title = NULL, xlab = "", ylab = "") %>%
# chart_data_line_width(values = c( "Peer Group" = 0) ) %>%
chart_data_line_style('none') %>% # having trouble making line disappear
chart_data_symbol("diamond") %>%
chart_data_size(10) %>%
set_theme(mschart_theme(
axis_text_x = fp_text(color = "black", font.size = 10, bold = T),
axis_text_y = fp_text(color = "black"),
axis_title_y = fp_text(color = "black"),
axis_title_x = fp_text(color = "black"),
grid_major_line_y = fp_border(width = 0, color="black"), # sirve para hacer cuadricula
grid_major_line_x = fp_border(width = 0, color="#F0F0F0"),
legend_text = fp_text(font.size = 10, bold = F),
legend_position = "t",
axis_ticks_y = fp_border(width = 1, color="black"),
axis_ticks_x = fp_border(width = 1, color="black"))) %>% chart_theme()
}
iris <- select(iris, c("Species", "Sepal.Length", "Sepal.Width"))
iris_melted <- melt(iris, id.vars = c("Species"))
diamond_chart<- diamondLineWrapper(iris_melted, x = "variable", y = "value", group = "Species")
doc <- read_pptx()
doc <- add_slide(doc, layout = "Title and Content", master = "Office Theme")
doc <- ph_with(doc, value = diamond_chart, location = ph_location_fullsize())
print(doc, target = "example.pptx")
The view I want :
The view I currently get :
Please let me know if there is something that Im doing wrong or am missing. Or if you think there is a better way to create the view as in the image
Thank You !
The text was updated successfully, but these errors were encountered: