JavaScript preprocessors can help make authoring JavaScript easier and more convenient. For instance, CoffeeScript can help prevent easy-to-make mistakes and offer a cleaner syntax and Babel can bring ECMAScript 6 features to browsers that only support ECMAScript 5.
Any URL's added here will be added as <script>
s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.
You can apply a script from anywhere on the web to your Pen. Just put a URL to it here and we'll add it, in the order you have them, before the JavaScript in the Pen itself.
If the script you link to has the file extension of a preprocessor, we'll attempt to process it before applying.
You can also link to another Pen here, and we'll pull the JavaScript from that Pen and include it. If it's using a matching preprocessor, we'll combine the code before preprocessing, so you can use the linked Pen as a true dependency.
HTML Settings
Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>amCharts examples</title>
<link rel="stylesheet" href="style.css" type="text/css">
<script src="../amcharts/amcharts.js" type="text/javascript"></script>
<script src="../amcharts/xy.js" type="text/javascript"></script>
</head>
<body>
<div id="chartdiv" style="width: 600px; height: 400px;"></div>
</body>
</html>
body {
font-family: Tahoma,Arial,Verdana;
font-size: 12px;
color: black;
}
a:link {color: #84c4e2;}
a:visited {color:#84c4e2;}
a:hover {color: #cd82ad;}
a:active {color: #84c4e2;}
var chart;
var chartData = [
{
"date": "2015-01-01",
"ay": 0.5,
"by": 2.2
},
{
"date": "2015-01-02",
"ay": 1.3,
"by": 4.9
},
{
"date": "2015-01-03",
"ay": 2.3,
"by": 5.1
},
{
"date": "2015-01-04",
"ay": 2.8,
"by": 5.3
},
{
"date": "2015-01-05",
"ay": 3.5,
"by": 6.1
},
{
"date": "2015-01-06",
"ay": 5.1,
"by": 8.3
},
{
"date": "2015-01-07",
"ay": 6.7,
"by": 10.5
},
{
"date": "2015-01-08",
"ay": 8,
"by": 12.3
},
{
"date": "2015-01-09",
"ay": 8.9,
"by": 14.5
},
{
"date": "2015-01-10",
"ay": 9.7,
"by": 15
},
{
"date": "2015-01-11",
"ay": 10.4,
"by": 18.8
},
{
"date": "2015-01-12",
"ay": 11.7,
"by": 19
}
];
AmCharts.ready(function () {
// XY CHART
chart = new AmCharts.AmXYChart();
chart.dataDateFormat = "YYYY-MM-DD";
chart.dataProvider = chartData;
chart.startDuration = 1;
// AXES
// X
var xAxis = new AmCharts.ValueAxis();
xAxis.title = "X Axis";
xAxis.position = "bottom";
xAxis.dashLength = 1;
xAxis.axisAlpha = 0;
xAxis.type = "date";
xAxis.autoGridCount = true;
chart.addValueAxis(xAxis);
// Y
var yAxis = new AmCharts.ValueAxis();
yAxis.position = "left";
yAxis.title = "Y Axis";
yAxis.dashLength = 1;
yAxis.axisAlpha = 0;
yAxis.autoGridCount = true;
chart.addValueAxis(yAxis);
// GRAPHS
// triangles up
var graph1 = new AmCharts.AmGraph();
graph1.lineColor = "#FF6600";
graph1.balloonText = "x:[[x]] y:[[y]]";
graph1.xField = "date";
graph1.yField = "ay";
graph1.lineAlpha = 1;
graph1.type = "smoothedLine";
graph1.bullet = "triangleUp";
chart.addGraph(graph1);
// triangles down
var graph2 = new AmCharts.AmGraph();
graph2.lineColor = "#FCD202";
graph2.balloonText = "x:[[x]] y:[[y]]";
graph2.xField = "date";
graph2.yField = "by";
graph2.lineAlpha = 1;
graph2.type = "smoothedLine";
graph2.bullet = "triangleDown";
chart.addGraph(graph2);
// first trend line
var trendLine = new AmCharts.TrendLine();
trendLine.lineColor = "#FF6600";
trendLine.initialXValue = 1;
trendLine.initialValue = 2;
trendLine.finalXValue = 12;
trendLine.finalValue = 11;
chart.addTrendLine(trendLine);
// second trend line
trendLine = new AmCharts.TrendLine();
trendLine.lineColor = "#FCD202";
trendLine.initialXValue = 1;
trendLine.initialValue = 1;
trendLine.finalXValue = 12;
trendLine.finalValue = 19;
chart.addTrendLine(trendLine);
// CURSOR
var chartCursor = new AmCharts.ChartCursor();
chart.addChartCursor(chartCursor);
// SCROLLBAR
var chartScrollbar = new AmCharts.ChartScrollbar();
chart.addChartScrollbar(chartScrollbar);
// WRITE
chart.write("chartdiv");
});
Also see: Tab Triggers