ardata-fr / mschart

:bar_chart: mschart: office charts from R
https://ardata-fr.github.io/mschart
Other
131 stars 25 forks source link

scatterchart with linemarkers #66

Closed thuyvlu closed 1 year ago

thuyvlu commented 3 years ago

Hi,

When using ms_scatterchart with linemarker, the data points are connected based on their y values. Do you know if there is anything I can adjust in my code to have them connected by their x values?

Thank you!

library(tidyverse)
library(mschart)
library(officer)

data <-
  data.frame(
    y = c(1, 5, 2, 9, 7.5, 6, 8, 1, 3, 7),
    x = c(1, 3, 4, 5.5, 6, 1, 3, 4, 5.5, 6),
    color = c(rep("red", 5), rep("blue", 5))
  )

chart <-
  ms_scatterchart(data = data,
                  x = "x",
                  y = "y",
                  group = "color") %>%
  chart_settings(style = "lineMarker")

pptx_obj <- read_pptx() %>%
  add_slide(layout = "Title and Content", master = "Office Theme") %>%
  ph_with(value = chart, location = ph_location_type(type = "body")) %>%
  print(target = "example_linemarker.pptx")

image