plotly / plotly/plotly.R

ggplotly not working with control chart library ggQC

未关闭
#2,177 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

主要语言
R
星标
2.7k
派生
641
PR 合并指标
30 天内没有已合并 PR

描述

Brief description of the problem:

Adding some lines and labels using the ggQC library causes a hard fail.

This code works with ggplotly:

      min_date = as.Date(min(lots_df_filtered()$DATE))
      max_date = as.Date(max(lots_df_filtered()$DATE))
      if (!is.na(min_date)) {
        num_days = length(seq(from = min_date, to = max_date, by = 'day')) - 1
        date_breaks <- if(num_days <= 31) 'day' else 'week'
        XmR_Plot <- 
            ggplot(lots_df_filtered(), aes(x = as.Date(DATE), y = YRS_YIELD)) +
            geom_point(alpha = .5) + geom_line() +
            labs(title=paste0(input$mfg_step_name, ' Lot Yield Control Chart')) +
            scale_x_date(date_breaks=date_breaks) +
            theme_ipsum_ps() +
            theme(axis.text.x = element_text(angle = 60, vjust = 0.5, hjust=1),
                  axis.title.x=element_blank()) 
        output$lot_time_series <- renderPlotly(ggplotly(XmR_Plot))
      }`

Produces a nice chart as so:

image

The following code results in an error (alpha must be of length 1 or the same length as x):

      min_date = as.Date(min(lots_df_filtered()$DATE))
      max_date = as.Date(max(lots_df_filtered()$DATE))
      if (!is.na(min_date)) {
        num_days = length(seq(from = min_date, to = max_date, by = 'day')) - 1
        date_breaks <- if(num_days <= 31) 'day' else 'week'
        XmR_Plot <- 
            ggplot(lots_df_filtered(), aes(x = as.Date(DATE), y = YRS_YIELD)) +
            geom_point(alpha = .5) + geom_line() +
            stat_QC(method = "XmR",      
                    auto.label = T, 
                    label.digits = 2,   
                    show.1n2.sigma = T   
                    ) +
            labs(title=paste0(input$mfg_step_name, ' Lot Yield Control Chart')) +
            scale_x_date(date_breaks=date_breaks) +
            theme_ipsum_ps() +
            theme(axis.text.x = element_text(angle = 60, vjust = 0.5, hjust=1),
                  axis.title.x=element_blank()) 
        output$lot_time_series <- renderPlotly(ggplotly(XmR_Plot))
      }

Here is what the ggplot looks like when I do not use ggplotly and do use ggCC:

image

Could this be related to the ggplotly argument layerData? Any help is appreciated.

thx

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

首先运行提供的 R 复现代码,使用 ggplotly、ggplot2 和 ggQC,并将正常工作的图与使用 stat_QC() 的版本进行比较。调查报告的“alpha must be of length 1 or the same length as x”失败,并确认控制图图层能够通过 ggplotly 进行渲染,而不会发生硬错误。

由索引模型根据 Issue 内容生成。

评估

技术栈
r
领域
data-visualization
Issue 类型
缺陷
难度
3/5
预计耗时
1-2 天
活跃度
停滞
描述清晰度
基本清楚
新手友好度
35/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。