更改 googleVis 时间线图表上的轴限制
Change axis limits on googleVis timeline chart
我想为 R googleVis 时间线图表设置具体的开始和结束日期。例如,我希望下面的图表从 1780 开始,到 1815 结束。我已经搜索了文档并尝试了其他图表类型的一些选项,但我无法让它们中的任何一个工作。
library(googleVis)
datTL <- data.frame(Position=c(rep("President", 3), rep("Vice", 3)),
Name=c("Washington", "Adams", "Jefferson",
"Adams", "Jefferson", "Burr"),
start=as.Date(x=rep(c("1789-03-29", "1797-02-03",
"1801-02-03"),2)),
end=as.Date(x=rep(c("1797-02-03", "1801-02-03",
"1809-02-03"),2)))
Timeline <- gvisTimeline(data=datTL,
rowlabel="Name",
barlabel="Position",
start="start",
end="end",
options=list(timeline="{groupByRowLabel:false}",
backgroundColor='#ffd',
height=350,
colors="['#cbb69d', '#603913', '#c69c6e']"))
plot(Timeline)
您可以在选项中通过 hAxis
提供水平轴的 minValue
和 maxValue
,如下所示:
option=list(hAxis="{minValue: new Date(1785, 0, 0), maxValue: new Date(1810, 0, 0)}"))
整个剧情是这样的:
library(googleVis)
datTL <- data.frame(Position=c(rep("President", 3), rep("Vice", 3)),
Name=c("Washington", "Adams", "Jefferson",
"Adams", "Jefferson", "Burr"),
start=as.Date(x=rep(c("1789-03-29", "1797-02-03",
"1801-02-03"),2)),
end=as.Date(x=rep(c("1797-02-03", "1801-02-03",
"1809-02-03"),2)))
option_list <- list(timeline="{groupByRowLabel:false}",
backgroundColor='#ffd',
height=350,
colors="['#cbb69d', '#603913', '#c69c6e']",
hAxis="{minValue: new Date(1785, 0, 0), maxValue: new Date(1810, 0, 0)}")
Timeline <- gvisTimeline(data=datTL,
rowlabel="Name",
barlabel="Position",
start="start",
end="end",
options=option_list)
plot(Timeline)
我想为 R googleVis 时间线图表设置具体的开始和结束日期。例如,我希望下面的图表从 1780 开始,到 1815 结束。我已经搜索了文档并尝试了其他图表类型的一些选项,但我无法让它们中的任何一个工作。
library(googleVis)
datTL <- data.frame(Position=c(rep("President", 3), rep("Vice", 3)),
Name=c("Washington", "Adams", "Jefferson",
"Adams", "Jefferson", "Burr"),
start=as.Date(x=rep(c("1789-03-29", "1797-02-03",
"1801-02-03"),2)),
end=as.Date(x=rep(c("1797-02-03", "1801-02-03",
"1809-02-03"),2)))
Timeline <- gvisTimeline(data=datTL,
rowlabel="Name",
barlabel="Position",
start="start",
end="end",
options=list(timeline="{groupByRowLabel:false}",
backgroundColor='#ffd',
height=350,
colors="['#cbb69d', '#603913', '#c69c6e']"))
plot(Timeline)
您可以在选项中通过 hAxis
提供水平轴的 minValue
和 maxValue
,如下所示:
option=list(hAxis="{minValue: new Date(1785, 0, 0), maxValue: new Date(1810, 0, 0)}"))
整个剧情是这样的:
library(googleVis)
datTL <- data.frame(Position=c(rep("President", 3), rep("Vice", 3)),
Name=c("Washington", "Adams", "Jefferson",
"Adams", "Jefferson", "Burr"),
start=as.Date(x=rep(c("1789-03-29", "1797-02-03",
"1801-02-03"),2)),
end=as.Date(x=rep(c("1797-02-03", "1801-02-03",
"1809-02-03"),2)))
option_list <- list(timeline="{groupByRowLabel:false}",
backgroundColor='#ffd',
height=350,
colors="['#cbb69d', '#603913', '#c69c6e']",
hAxis="{minValue: new Date(1785, 0, 0), maxValue: new Date(1810, 0, 0)}")
Timeline <- gvisTimeline(data=datTL,
rowlabel="Name",
barlabel="Position",
start="start",
end="end",
options=option_list)
plot(Timeline)