Displaying bullets on specified points only

Type tutorial

In some cases you might need to show bullet only at a specific data point, not all of them. Or you might need to have  a different from default bullet for some points. To do this, you should first add bullet field in your data provider, for example: var chartData = [{ “date”: “2009-10-26”, “value”: […]

Interacting between JavaScript Charts and JavaScript Maps

Type tutorial

Say, you have a map on your page. Perfect. Now you want to add a little chart. Easy. Finally you want the chart to go over the map, and, to further complicate things, want the chart to update it’s data when user clicks particular countries on the map. It may be easier than you think. […]

User defined min/max values of Value Axis

Type tutorial

You can use minimum and maximum properties of ValueAxis to set starting and ending value for your value axis. However, those are just “suggestions”. The chart will always struggle to adjust the scale of the value axis so that it displays “pretty” starting and ending values, as well as nice intermediate steps. So if you set, say, the scale […]

Combined stacked line/area graphs with non-stacked ones

Type tutorial

To prevent the line graph from stacking with another graphs on a stacked line/area chart, just set its stackable property to false. I.e.: graph.stackable = false; The above works for both regular JavaScript Charts and JavaScript Stock Charts.

Resizing chart for print

Type tutorial

Usually browsers use different resolution when printing web pages. If you have charts that are wider than ~600-700 pixels, they will print as cropped. To overcome this, use the following code to make the charts redraw using new dimensions before the page is printed: (function() { var beforePrint = function() { for(var i = 0; […]

Putting a legend outside the chart area

Type tutorial

Chart legend is a great visual tool that makes charts event more usable and easy to comprehend. However, sometimes it’s size gets unpredictable. If there are a lot of items in the legend, the actual chart gets shrunk in order to accommodate space for the legend. This may lead to unattractive situations like this: Ain’t […]

Make the pie chart to take the whole space of the container

Type tutorial

In order for the pie to take the whole width/height of the container you will need to: 1) Disable callouts / labels; 2) Set all margins to zero; 3) Disable slice pullout functionality. Like this: chart.labelsEnabled = false; chart.autoMargins = false; chart.marginTop = 0; chart.marginBottom = 0; chart.marginLeft = 0; chart.marginRight = 0; chart.pullOutRadius = […]

Replacing axis labels with arbitrary text

Type tutorial

Although you can format value axis labels like duration, add unit to the left or right of the value, you might need something more – for example, to replace numeric values of value axis with some strings or add some text to category axis labels. ValueAxis has labelFunction property for that. If you set some function […]

Non-English months / weekdays

Type tutorial

Month/weekday names can be set on all charts using the following properties of AmCharts class: monthNames, shortMonthNames, dayNames and shortDayNames. So, to translate month names to German, you should set: AmCharts.monthNames = [   ‘Januar’,   ‘Februar’,   ‘März’,   ‘April’,   ‘Mai’,   ‘Juni’,   ‘Juli’,   ‘August’,   ‘September’,   ‘Oktober’,   ‘November’,   ‘Dezember’];

Multi-segmented line graph

Type tutorial

Some time ago, in order to have multi-segmented line chart (the one where line color or fill color changes at some point) you had to add several different graphs and this wasn’t very straight forward task. However since v3 we added lineColorField, fillColorsField and dashLengthField properties to AmGraph and now you can do it very […]