initialize,AmChart-method {rAmCharts} | R Documentation |
Creates an AmChart
Description
Method to initialize any S4 class provided by the package.
Usage
## S4 method for signature 'AmChart'
initialize(
.Object,
allLabels,
arrows,
axes,
balloon,
categoryAxis,
categoryField,
chartCursor,
chartScrollbar,
creditsPosition,
dataProvider,
graphs,
graph,
guides,
legend,
segmentsField,
theme,
titles,
trendLines,
type,
valueAxes,
valueAxis,
valueScrollbar,
...
)
amChart(
allLabels,
arrows,
axes,
balloon,
categoryAxis,
categoryField,
chartCursor,
chartScrollbar,
creditsPosition,
dataProvider,
graph,
graphs,
guides,
legend,
segmentsField,
theme,
titles,
trendLines,
type,
valueAxes,
valueAxis,
...
)
amAngularGaugeChart(arrows, titles, axes, ...)
amFunnelChart(dataProvider, marginLeft = 10, marginRight = 10, ...)
amRadarChart(
allLabels,
balloon,
categoryField,
creditsPosition,
dataProvider,
graphs,
guides,
legend,
titles,
valueAxes,
...
)
amSerialChart(
allLabels,
balloon,
categoryAxis,
categoryField,
chartCursor,
chartScrollbar,
creditsPosition,
dataProvider,
graphs,
guides,
legend,
titles,
trendLines,
valueAxes,
...
)
amPieChart(
allLabels,
balloon,
creditsPosition,
dataProvider,
legend,
titles,
...
)
amGanttChart(categoryField, dataProvider, graph, segmentsField, valueAxis, ...)
amXYChart(creditsPosition, dataProvider, graphs, ...)
setAllLabels(.Object, allLabels)
## S4 method for signature 'AmChart,list'
setAllLabels(.Object, allLabels)
addLabel(.Object, label = NULL, ...)
## S4 method for signature 'AmChart,LabelOrMissing'
addLabel(.Object, label = NULL, ...)
setArrows(.Object, arrows = NULL)
## S4 method for signature 'AmChart'
setArrows(.Object, arrows = NULL)
addArrow(.Object, arrow = NULL, ...)
## S4 method for signature 'AmChart,GaugeArrowOrMissing'
addArrow(.Object, arrow = NULL, ...)
setAxes(.Object, axes, ...)
## S4 method for signature 'AmChart,list'
setAxes(.Object, axes)
addAxe(.Object, axe = NULL, ...)
## S4 method for signature 'AmChart,GaugeAxisOrMissing'
addAxe(.Object, axe = NULL, ...)
addAxis(.Object, axis = NULL, ...)
## S4 method for signature 'AmChart,GaugeAxisOrMissing'
addAxis(.Object, axis = NULL, ...)
## S4 method for signature 'AmChart,AmBalloonOrMissing'
setBalloon(.Object, amBalloon = NULL, ...)
setCategoryAxis(.Object, categoryAxis = NULL, ...)
## S4 method for signature 'AmChart'
setCategoryAxis(.Object, categoryAxis = NULL, ...)
setCategoryField(.Object, categoryField)
## S4 method for signature 'AmChart,character'
setCategoryField(.Object, categoryField)
setChartCursor(.Object, chartCursor = NULL, ...)
## S4 method for signature 'AmChart,ChartCursorOrMissing'
setChartCursor(.Object, chartCursor = NULL, ...)
setChartScrollbar(.Object, chartScrollbar = NULL, ...)
## S4 method for signature 'AmChart,ChartScrollbarOrMissing'
setChartScrollbar(.Object, chartScrollbar = NULL, ...)
setCreditsPosition(.Object, creditsPosition)
## S4 method for signature 'AmChart,character'
setCreditsPosition(.Object, creditsPosition)
setDataLoader(.Object, url, format, ...)
## S4 method for signature 'AmChart,character,character'
setDataLoader(.Object, url, format, ...)
## S4 method for signature 'AmChart,ANY,logicalOrMissing'
setDataProvider(.Object, dataProvider, keepNA = TRUE)
setGraphs(.Object, graphs)
## S4 method for signature 'AmChart,list'
setGraphs(.Object, graphs)
addGraph(.Object, amGraph = NULL, ...)
## S4 method for signature 'AmChart,AmGraphOrMissing'
addGraph(.Object, amGraph = NULL, ...)
## S4 method for signature 'AmChart,AmGraphOrMissing'
setGraph(.Object, graph = NULL, ...)
setGuides(.Object, guides)
## S4 method for signature 'AmChart,list'
setGuides(.Object, guides)
## S4 method for signature 'AmChart,GuideOrMissing'
addGuide(.Object, guide = NULL, ...)
setLegend(.Object, amLegend = NULL, ...)
## S4 method for signature 'AmChart,AmLegendOrMissing'
setLegend(.Object, amLegend = NULL, ...)
addSegment(.Object, categoryIDs, sgts)
## S4 method for signature 'AmChart,numeric'
addSegment(.Object, categoryIDs, sgts)
addSubData(.Object, categoryIDs, data)
## S4 method for signature 'AmChart,numeric'
addSubData(.Object, categoryIDs, data)
setSubChartProperties(.Object, .subObject = NULL, ...)
## S4 method for signature 'AmChart'
setSubChartProperties(.Object, .subObject = NULL, ...)
setTheme(.Object, theme)
## S4 method for signature 'AmChart,character'
setTheme(.Object, theme)
setTitles(.Object, titles)
## S4 method for signature 'AmChart,list'
setTitles(.Object, titles)
addTitle(.Object, title = NULL, ...)
## S4 method for signature 'AmChart,TitleOrMissing'
addTitle(.Object, title = NULL, ...)
setTrendLines(.Object, trendLines)
## S4 method for signature 'AmChart,list'
setTrendLines(.Object, trendLines)
addTrendLine(.Object, trendLine = NULL, ...)
## S4 method for signature 'AmChart,TrendLineOrMissing'
addTrendLine(.Object, trendLine = NULL, ...)
## S4 method for signature 'AmChart,character'
setType(.Object, type)
setValueAxes(.Object, valueAxes)
## S4 method for signature 'AmChart,list'
setValueAxes(.Object, valueAxes)
addValueAxes(.Object, valueAxis = NULL, ...)
## S4 method for signature 'AmChart,ValueAxisOrMissing'
addValueAxes(.Object, valueAxis = NULL, ...)
addValueAxis(.Object, valueAxis = NULL, ...)
## S4 method for signature 'AmChart,ValueAxisOrMissing'
addValueAxis(.Object, valueAxis = NULL, ...)
## S4 method for signature 'AmChart,ValueAxisOrMissing'
setValueAxis(.Object, valueAxis = NULL, ...)
setValueScrollbar(.Object, valueScrollbar, ...)
## S4 method for signature 'AmChart,ChartScrollbarOrMissing'
setValueScrollbar(.Object, valueScrollbar, ...)
Arguments
.Object |
|
allLabels |
|
arrows |
|
axes |
|
balloon |
AmBalloon.
Creates the balloons (tooltips) of the chart.
It follows the mouse cursor when you roll-over the data items.
The framework automatically generates the instances you just have to adjust
the appearance to your needs.
Run |
categoryAxis |
CategoryAxis.
Read-only. Chart creates category axis itself.
If you want to change some properties,
you should get this axis from the chart and set properties to this object.
Run |
categoryField |
|
chartCursor |
ChartCursor.
Chart's cursor.
Run |
chartScrollbar |
ChartScrollbar.
Chart's scrollbar.
Run |
creditsPosition |
|
dataProvider |
|
graphs |
|
graph |
AmGraph.
Only valid for Gantt charts.
Gant chart actually creates multiple graphs (separate for each segment).
Properties of this graph are passed to each of the created graphs
- this allows you to control the look of segments.
Run |
guides |
|
legend |
AmLegend.
Legend of a chart.
Run |
segmentsField |
|
theme |
|
titles |
|
trendLines |
|
type |
|
valueAxes |
|
valueAxis |
ValueAxis.
Only valid for Gantt Charts.
Set it's type to "date" if your data is date or time based.
Run |
valueScrollbar |
ChartScrollbar. Value scrollbar, enables scrolling value axes. |
... |
In case of constructor |
marginLeft |
|
marginRight |
|
label |
(optional) Label.
Argument of method |
arrow |
(optional) GaugeArrow.
Argument of method |
axe |
(optional) GaugeAxis.
Argument of deprecated method |
axis |
(optional) GaugeAxis. same as axe. |
amBalloon |
AmBalloon, argument of method 'setBalloon'. |
url |
|
format |
|
keepNA |
object of class |
amGraph |
(optional) AmGraph. |
guide |
(optional) Guide.
Argument of method |
amLegend |
(optional) AmLegend. |
categoryIDs |
|
sgts |
|
data |
|
.subObject |
|
title |
(optional) Title, argument of method |
trendLine |
(optional) TrendLine.
Argument of method |
Details
amAngularGaugeChart is a shortcut for instantiating AmChart of type gauge
.
amFunnelChart is a shortcut
for instantiating AmChart of type funnel
.
amRadarChart is a shortcut
for instantiating AmChart of type radar
.
amSerialChart is a shortcut constructor
for instantiating AmChart of type serial
.
amPieChart is a shortcut constructor
for instantiating AmChart of type pie
.
amGanttChart is a constructor
for instantiating AmChart of type gantt
.
amXYChart is a shortcut constructor
for instantiating AmChart of type xy
.
Method 'addAxe' is deprecated, use 'addAxis'.
Method setGraph
is only valid for Gantt Charts.
'addSubData' allows to add subdata for a chart with drilldown.
In this case, categoryIDs indicates corresponding indice(s)
of the dataProvider
where to add the data.
For method addValueAxis
: valueAxis is optional. Method addValueAxes
is deprecated.
Method setValueAxis
is only valid for Gantt charts.
Value
(updated) AmChart with given properties.
See Also
Refer to https://docs.amcharts.com/3/javascriptcharts/.
Examples
## Not run:
new("AmChart", valueField = "value", theme = "patterns")
## End(Not run)
## Not run:
amChart(type = "pie")
## End(Not run)
## Not run:
amAngularGaugeChart()
## End(Not run)
## Not run:
amFunnelChart(marginLeft = 15)
## End(Not run)
## Not run:
amRadarChart()
## End(Not run)
## Not run:
amSerialChart(creditsPostion = "top-right")
## End(Not run)
## Not run:
amPieChart()
## End(Not run)
## Not run:
amGanttChart(segmentsField = "segments")
## End(Not run)
## Not run:
amXYChart()
## End(Not run)
## Not run:
allLabels <- list(label(text = "balloonText"), label(text = "column"))
amSerialChart(allLabels = allLabels)
## End(Not run)
# ---
## Not run:
addLabel(.Object = amSerialChart(), text = "balloonText")
# equivalent to:
label_obj <- label(text = "balloonText")
addLabel(.Object = amSerialChart(), label = label_obj)
## End(Not run)
# ---
## Not run:
arrows_ls <- list(gaugeArrow(value = 130), gaugeArrow(value = 150))
amAngularGaugeChart(arrows = arrows_ls)
## End(Not run)
# ---
## Not run:
chart <- addArrow(.Object = amAngularGaugeChart(), value = 10); print(chart)
# equivalent to:
gaugeArrow_obj <- gaugeArrow(value = 10)
addArrow(.Object = amAngularGaugeChart(), arrow = gaugeArrow_obj)
## End(Not run)
# ---
## Not run:
axes_ls <- list(gaugeAxis(value = 130), gaugeAxis(value = 150))
setAxes(.Object = amAngularGaugeChart(), axes = axes_ls)
# If possible, simplify your code by using the constructor:
amAngularGaugeChart(axes = axes_ls)
## End(Not run)
# ---
## Not run:
addAxis(.Object = amAngularGaugeChart(), startValue = 0, endValue = 100, valueInterval = 10)
# equivalent to:
gaugeAxis_obj <- gaugeAxis(startValue = 0, enValue = 100, valueInterval = 10)
addAxis(.Object = amAngularGaugeChart(), axis = gaugeAxis_obj)
## End(Not run)
# ---
## Not run:
setBalloon(.Object = amSerialChart(), adjustBorderColor = TRUE, fillColor = "#FFFFFF",
color = "#000000", cornerRadius = 5)
# equivalent to:
amBalloon_obj <- amBalloon(adjustBorderColor = TRUE, fillColor = "#FFFFFF",
color = "#000000", cornerRadius = 5)
setBalloon(.Object = amSerialChart(), amBalloon = amBalloon_obj)
## End(Not run)
# ---
## Not run:
setCategoryAxis(.Object = amSerialChart(), gridPosition = "start")
# equivalent to:
categoryAxis_obj <- categoryAxis(gridPosition = "start")
setCategoryAxis(.Object = amSerialChart(), categoryAxis = categoryAxis_obj)
## End(Not run)
# ---
setCategoryField(.Object = amSerialChart(), categoryField = "country")
# ---
## Not run:
# with default value, no argument needed
setChartCursor(.Object = amSerialChart())
# other example
setChartCursor(.Object = amSerialChart(), oneBallOnly = TRUE)
# equivalent to
chartCursor_obj <- chartCursor(oneBallOnly = TRUE)
setChartCursor(.Object = amSerialChart(), chartCursor = chartCursor_obj)
## End(Not run)
# ---
## Not run:
# Add the default scrollbar
setChartScrollbar(.Object = amSerialChart())
# equivalent to:
chartScrollbar_obj <- chartScrollbar(updateOnReleaseOnly = FALSE)
setChartScrollbar(.Object = amSerialChart(), chartScrollbar = chartScrollbar_obj)
## End(Not run)
# ---
## Not run:
setCreditsPosition(.Object = amPieChart(), creditsPosition = "top-right")
## End(Not run)
# ---
## Not run:
setDataLoader(.Object = amSerialChart(), url = "data.json", format = "json")
## End(Not run)
# ---
## Not run:
dataProvider_obj <- data.frame(key = c("FR", "US", "GER", "ENG", "IT" ),
value = round(runif(5, max = 100)))
setDataProvider(.Object = amPieChart(), dataProvider = dataProvider_obj)
## End(Not run)
# ---
## Not run:
graphs_ls <- list(graph(balloonText = "balloonText"), graph(type = "column"))
setGraphs(.Object = amSerialChart(), graphs = graphs_ls)
## End(Not run)
# ---
## Not run:
addGraph(.Object = amSerialChart(), balloonText = "balloonText", "type" = "column")
# equivalent to
amGraph_obj <- amGraph(balloonText = "balloonText", "type" = "column")
addGraph(.Object = amSerialChart(), amGraph = amGraph_obj)
## End(Not run)
# ---
## Not run:
print(setGraph(.Object = amGanttChart(), id = "amGraph-1"))
# equivalent to:
amGraph_obj <- amGraph(id = "amGraph-1")
setGraph(.Object = amGanttChart(), amGraph = amGraph_obj)
## End(Not run)
# ---
## Not run:
guides_ls <- list(guide(fillAlpha = .1), guide(fillAlpha = .5))
amSerialChart(guides = guides_ls)
## End(Not run)
# ---
## Not run:
chart <- addGuide(.Object = amSerialChart(), fillAlpha = .1, value = 0, toVAlue = 10)
print(chart)
# equivalent to
guide_obj <- guide(fillAlpha = .1, value = 0, toValue = 10, valueAxis = "1")
addGuide(.Object = amSerialChart(), guide = guide_obj)
## End(Not run)
## Not run:
setLegend(.Object = amChart(), amLegend = amLegend(useGraphSettings = TRUE))
# equivalent to:
setLegend(.Object = amChart(), useGraphSettings = TRUE)
## End(Not run)
# ---
## Not run:
pipeR::pipeline(
amGanttChart(segmentsField = "segments"),
setDataProvider(data.frame(category = c( "John", "Julia"))),
addSegment(1, data.frame(start = 7, duration = 2:3, task = c("Task #1", "Task #2"))),
addSegment(2, data.frame(start = 10, duration = 2:3, task = c("Task #1", "Task #2")))
)
# ---
ls <- list(data.frame(start = 7, duration = 2:3, task = c("Task #1", "Task #2")),
data.frame(start = 10, duration = 2:3, task = c("Task #1", "Task #2")))
pipeR::pipeline(
amGanttChart(segmentsField = "segments"),
setDataProvider(data.frame(category = c( "John", "Julia"))),
addSegment(1:2, ls)
)
## End(Not run)
# ---
## Not run:
amChart_obj <- amChart(dataProvider = data.frame(a = 1:5, b = 6:10))
addSubData(.Object = amChart_obj, categoryIDs = 3, data = data.frame(a = 1:10, b = 11:20))
## End(Not run)
# ---
## Not run:
setSubChartProperties(.Object = amSerialChart(), type = "serial")
## End(Not run)
# ---
## Not run:
setTheme(.Object = amPieChart(), theme = "dark")
## End(Not run)
# ---
## Not run:
titles_ls <- list(amTitle(text = "balloonText"), amTitle(text = "column"))
setTitles(.Object = amXYChart(), titles = titles_ls)
# or...
amXYChart(titles = titles_ls)
## End(Not run)
# ---
## Not run:
addTitle(.Object = amPieChart(), text = "balloonText", size = 15)
# equivalent to
title_obj <- amTitle(text = "balloonText", size = 15)
addTitle(.Object = amPieChart(), title = title_obj)
## End(Not run)
# ---
## Not run:
trendLines <- list(trendLine(initialValue = 1, finalValue = 5),
trendLine(initialValue = 7, finalValue = 19))
setTrendLines(.Object = amSerialChart(), trendLines = trendLines)
# or...
amSerialChart(trendLines = trendLines) # Equivalent
## End(Not run)
# ---
## Not run:
addTrendLine(.Object = amSerialChart(), initialValue = 1, initialXValue = 1,
finalValue = 11, finalXValue = 12)
# equivalent to:
trendLine_obj <- trendLine(initialValue = 1, initialXValue = 1, finalValue = 11, finalXValue = 12)
chart <- addTrendLine(.Object = amSerialChart(), trendLine = trendLine_obj); print(chart)
## End(Not run)
# ---
## Not run:
setType(.Object = amChart(), type = "pie")
# equivalent to:
amPieChart()
## End(Not run)
## Not run:
valueAxes <- list(valueAxis(axisTitleOffset = 12, tickLength = 10),
valueAxis(axisTitleOffset = 10, tickLength = 10))
setValueAxes(.Object = amSerialChart(), valueAxes = valueAxes)
# or...
amSerialChart(valueAxes = valueAxes)
## End(Not run)
# ---
## Not run:
print(addValueAxis(.Object = amSerialChart(), axisTitleOffset = 12, tickLength = 10, title = "foo"))
# equivalent to:
valueAxis_obj <- valueAxis(axisTitleOffset = 12, tickLength = 10, title = "foo")
addValueAxis(.Object = amSerialChart(), valueAxis = valueAxis_obj)
## End(Not run)
# ---
## Not run:
setValueAxis(.Object = amGanttChart())
setValueAxis(.Object = amGanttChart(), type = "date")
## End(Not run)
## Not run:
valueScrollbar_obj <- chartScrollbar(updateOnReleaseOnly = FALSE)
chart <- setValueScrollbar(.Object = amSerialChart(), valueScrollbar = valueScrollbar_obj)
print(chart)
# or...
amSerialChart(updateOnReleaseOnly = FALSE)
## End(Not run)
# ---