小编Sal*_*han的帖子

plotly - 响应宽度,固定高度

我尝试制作一个适合可滚动父 div 的绘图图表:

data = {
          Name: {0:'name1', 1:'name2', 2: 'name3', 
                 3:'n4',4:'ewf',5:'dgag', 6:'faf', 7:'dfss',
                 8:'345',9:'9',10:'23435', 11:'2e345',12:'3345', 13:'a345', 
                 14:'34g5', 15:'3f45'},
          Count: {0:1023, 1:2345, 3:3875,4:234,5:3456, 6:84, 7:7763,
                  8:345,9:2345,10:2345, 11:2345,12:345, 13:345, 14:345, 
                  15:345},
          Index: {0:35, 1:200, 2:160, 3:24,4:234,5:356, 6:84, 7:73,
                  8:345,9:2345,10:2345, 11:2345,12:345, 13:345, 14:345, 
                  15:345}
       }
$('#p1').html("");
console.log(data)
Plotly.newPlot('p1',
    [{
        type: 'bar',
        x: Object.values(data.Count),
        y: Object.values(data.Name),
        base: 0,
        orientation: 'h'
    },{
        type: 'bar',
        x: Object.values(data.Index).map(function (e) {
            e = e-100
            return e
        }),
        y: Object.values(data.Name),
        base: 100,
        orientation: 'h',
        xaxis: 'x2',
        yaxis: 'y' …
Run Code Online (Sandbox Code Playgroud)

javascript plotly.js

6
推荐指数
1
解决办法
1万
查看次数

闪亮-调整sidebarPanel()相对于mainPanel()的宽度

我有以下代码段可作为我闪亮的UI的一部分:

fluidPage(
      titlePanel("Complaints this month"),
      tabsetPanel(
        tabPanel(
          "Opened",
          sidebarLayout(
            sidebarPanel(
              sliderInput('sampleSize', 'Sample Size', min = 1, max = nrow(ThisMonthCreated),
                          value = 1000, step = 500, round = 0),
              selectInput('Openedx', 'X', choices = nms1, selected = "ActualDateCreated"),
              selectInput('Openedy', 'Y', choices = nms1, selected = "TimeToAcknowledge"),
              selectInput('Openedcolor', 'Color', choices = nms1, selected = "SimpleBusinessArea"),

              selectInput('Openedfacet_row', 'Facet Row', c(None = '.', nms1), selected = "none"),
              selectInput('Openedfacet_col', 'Facet Column', c(None = '.', nms1)),
              sliderInput('OpenedHeight', 'Height of plot (in pixels)', 
                          min = 100, max = …
Run Code Online (Sandbox Code Playgroud)

r

2
推荐指数
1
解决办法
6772
查看次数

列之间的累积减法

我有12列:

11是来自名为"预测"的df中的"day0","day1"......"day10"

1是名为"人数"的df中的"10个内容"

两个dfs都具有相同的长度.

我想从预测$ day10中扣除10个内部的人数$,除非它达到0,在这种情况下我希望它从第9天减去余数,依此类推,直到它达到day0.

目前我有下面的代码 - 虽然很长,可能不是最有效的方式 - 似乎工作,但我想做同样的程序,多个列的数量不同.希望它能解释我正在尝试做什么.

for(i in 1:i) if(forecasting$day10[i]>headcount$within10closures[i]){
  forecasting$day10[i] <- forecasting$day10[i] - headcount$within10closures[i]
} else {
  forecasting$day10[i] <- 0
  subtraction <- headcount$within10closures[i]-forecasting$day10[i]
  if(forecasting$day9[i]>subtraction){
    forecasting$day9[i] - (subtraction)
  } else {
    forecasting$day9[i] <- 0
    subtraction <- subtraction - forecasting$day9[i]
    if(forecasting$day8[i]>subtraction){
      forecasting$day8[i] - (subtraction)
    } else {
      forecasting$day8[i] <- 0
      subtraction <- subtraction - forecasting$day8[i]
      if(forecasting$day7[i]>subtraction){
        forecasting$day7[i] - (subtraction)
      } else {
        forecasting$day7[i] <- 0
        subtraction <- subtraction - forecasting$day7[i]
        if(forecasting$day6[i]>subtraction){
          forecasting$day6[i] - (subtraction)
        } else …
Run Code Online (Sandbox Code Playgroud)

r

1
推荐指数
1
解决办法
221
查看次数

标签 统计

r ×2

javascript ×1

plotly.js ×1