Creates an AmChart

Description

Method to initialize any S4 class provided by the package.

Usage

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
## 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

AmChart.

allLabels

list of Label. Example of a label object, with all possible properties: label(x = 20, y = 20, text = "this is a label", align = "left", size = 12, color = "#CC0000", alpha = 1, rotation = 0, bold = TRUE, url = "http=//www.amcharts.com"). Run api("Label") for more informations.

arrows

list of GaugeArrow. Only valid for gauge charts. Run api("GaugeArrow") for more informations.

axes

list of GaugeAxis properties. Only valid for gauge charts. Run api("GaugeAxis") for more informations.

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 api("AmBalloon") for more informations.

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 api("CategoryAxis") for more informations.

categoryField

character, category field name indicates the name of the field in your dataProvider object which will be used for category axis values.

chartCursor

ChartCursor. Chart's cursor. Run api("ChartCursor") for more informations.

chartScrollbar

ChartScrollbar. Chart's scrollbar. Run api("ChartScrollbar") for more informations.

creditsPosition

character, specifies position of the amCharts' website link. Allowed values are: "top-left", "top-right", "bottom-left" and "bottom-right".

dataProvider

data.frame, containing the data.

graphs

list of AmGraph. Creates the visualization of the data in following types: line, column, step line, smoothed line, olhc and candlestick. Run api("AmGraph") for more informations.

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 api("AmGraph") for more informations.

guides

list of Guide. Instead of adding guides to the axes, you can push all of them to this array. In case guide has category or date defined, it will automatically be assigned to the category axis, otherwise to the first value axis, unless you specify a different valueAxes for the guide. Run api("Guide") for more informations.

legend

AmLegend. Legend of a chart. Run api("AmLegend") for more informations.

segmentsField

character, segments field in your data provider. Only valid for Gantt Charts.

theme

character, theme of a chart. Config files of themes can be found in amcharts/themes/ folder. See http://www.amcharts.com/tutorials/working-with-themes/.

titles

list of Title. Run api("Title") for more informations.

trendLines

list of TrendLine objects added to the chart. You can add trend lines to a chart using this list or access already existing trend lines. Run api("TrendLine") for more informations.

type

character, possible types are: "serial", "pie", "radar", "xy", "radar", "funnel", "gauge", "stock". See details about using argument type. (type map is in development).

valueAxes

list of ValueAxis. Chart creates one value axis automatically, so if you need only one value axis, you don't need to create it. Run api("ValueAxis") for more informations.

valueAxis

ValueAxis. Only valid for Gantt Charts. Set it's type to "date" if your data is date or time based. Run api("ValueAxis") for more informations.

valueScrollbar

ChartScrollbar. Value scrollbar, enables scrolling value axes.

...

In case of constructor new("AmChart") or amChart() Dots represent other properties to set to the AmChart object. See http://docs.amcharts.com/3/javascriptstockchart/AmChart. In case of setters, dots represent properties of the object to add. See examples.

marginLeft

character, left margin of the chart.

marginRight

character, right margin of the chart.

label

(optional) Label. Argument of method addLabel.

arrow

(optional) GaugeArrow. Argument of method addArrow.

axe

(optional) GaugeAxis. Argument of deprecated method addAxe.

axis

(optional) GaugeAxis. same as axe.

amBalloon

AmBalloon, argument of method 'setBalloon'.

url

character.

format

character.

keepNA

object of class logical, default TRUE. Indicates if NULL values have to be kept or ignored.

amGraph

(optional) AmGraph.

guide

(optional) Guide. Argument of method addGuide.

amLegend

(optional) AmLegend.

categoryIDs

numeric, see details.

sgts

data.frame ( or list of data.frame for multiple add ).

data

data.frame. Data to draw at the second level, after clicking on the column.

.subObject

AmChart.

title

(optional) Title, argument of method addTitle.

trendLine

(optional) TrendLine. Argument of method addTrendLine.

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 http://docs.amcharts.com/3/javascriptcharts/.

Examples

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
new("AmChart", valueField = "value", theme = "patterns")


amChart(type = "pie")


amAngularGaugeChart()


amFunnelChart(marginLeft = 15)


amRadarChart()


amSerialChart(creditsPostion = "top-right")


amPieChart()


amGanttChart(segmentsField = "segments")


amXYChart()


allLabels <- list(label(text = "balloonText"), label(text = "column"))
amSerialChart(allLabels = allLabels)

# ---

addLabel(.Object = amSerialChart(), text = "balloonText")
# equivalent to:
label_obj <- label(text = "balloonText")
addLabel(.Object = amSerialChart(), label = label_obj)

# ---

arrows_ls <- list(gaugeArrow(value = 130), gaugeArrow(value = 150))
amAngularGaugeChart(arrows = arrows_ls)

# ---

chart <- addArrow(.Object = amAngularGaugeChart(), value = 10); print(chart)
# equivalent to:
gaugeArrow_obj <- gaugeArrow(value = 10)
addArrow(.Object = amAngularGaugeChart(), arrow = gaugeArrow_obj)

# ---

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)

# ---

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)

# ---

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)

# ---

setCategoryAxis(.Object = amSerialChart(), gridPosition = "start")
# equivalent to:
categoryAxis_obj <- categoryAxis(gridPosition = "start")
setCategoryAxis(.Object = amSerialChart(), categoryAxis = categoryAxis_obj)

# ---
setCategoryField(.Object = amSerialChart(), categoryField = "country")
# ---

# 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)

# ---

# Add the default scrollbar
setChartScrollbar(.Object = amSerialChart())
# equivalent to:
chartScrollbar_obj <- chartScrollbar(updateOnReleaseOnly = FALSE)
setChartScrollbar(.Object = amSerialChart(), chartScrollbar = chartScrollbar_obj)

# ---

setCreditsPosition(.Object = amPieChart(), creditsPosition = "top-right")

# ---

setDataLoader(.Object = amSerialChart(), url = "data.json", format = "json")

# ---

dataProvider_obj <- data.frame(key = c("FR", "US", "GER", "ENG", "IT" ),
                               value = round(runif(5, max = 100)))
setDataProvider(.Object = amPieChart(), dataProvider = dataProvider_obj)

# ---

graphs_ls <- list(graph(balloonText = "balloonText"), graph(type = "column"))
setGraphs(.Object = amSerialChart(), graphs = graphs_ls)

# ---

addGraph(.Object = amSerialChart(), balloonText = "balloonText", "type" = "column")
# equivalent to
amGraph_obj <- amGraph(balloonText = "balloonText", "type" = "column")
addGraph(.Object = amSerialChart(), amGraph = amGraph_obj)

# ---

print(setGraph(.Object = amGanttChart(), id = "amGraph-1"))
# equivalent to:
amGraph_obj <- amGraph(id = "amGraph-1")
setGraph(.Object = amGanttChart(), amGraph = amGraph_obj)

# ---

guides_ls <- list(guide(fillAlpha = .1), guide(fillAlpha = .5))
amSerialChart(guides = guides_ls)

# ---

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)


setLegend(.Object = amChart(), amLegend = amLegend(useGraphSettings = TRUE))
# equivalent to:
setLegend(.Object = amChart(), useGraphSettings = TRUE)

# ---

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)
)

# ---

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))

# ---

setSubChartProperties(.Object = amSerialChart(), type = "serial")

# ---

setTheme(.Object = amPieChart(), theme = "dark")

# ---

titles_ls <- list(amTitle(text = "balloonText"), amTitle(text = "column"))
setTitles(.Object = amXYChart(), titles = titles_ls)
# or...
amXYChart(titles = titles_ls)

# ---

addTitle(.Object = amPieChart(), text = "balloonText", size = 15)
# equivalent to
title_obj <- amTitle(text = "balloonText", size = 15)
addTitle(.Object = amPieChart(), title = title_obj)

# ---

trendLines <- list(trendLine(initialValue = 1, finalValue = 5),
                   trendLine(initialValue = 7, finalValue = 19))
setTrendLines(.Object = amSerialChart(), trendLines = trendLines)
# or... 
amSerialChart(trendLines = trendLines) # Equivalent

# ---

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)

# ---

setType(.Object = amChart(), type = "pie")
# equivalent to:
amPieChart()


valueAxes <- list(valueAxis(axisTitleOffset = 12, tickLength = 10),
                  valueAxis(axisTitleOffset = 10, tickLength = 10))
setValueAxes(.Object = amSerialChart(), valueAxes = valueAxes)
# or...
amSerialChart(valueAxes = valueAxes)

# ---

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)

# ---

setValueAxis(.Object = amGanttChart())
setValueAxis(.Object = amGanttChart(), type = "date")


valueScrollbar_obj <- chartScrollbar(updateOnReleaseOnly = FALSE)
chart <- setValueScrollbar(.Object = amSerialChart(), valueScrollbar = valueScrollbar_obj)
print(chart)
# or...
amSerialChart(updateOnReleaseOnly = FALSE)

# ---

Want to suggest features or report bugs for rdrr.io? Use the GitHub issue tracker.