Pascal_Kelm

html test

Jan 3rd, 2017
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 4.72 KB | None | 0 0
  1. <head>
  2. </head>
  3. <body>
  4. <!-- Styles -->
  5. <style>
  6. #chartdiv {
  7.   width: 100%;
  8.   height: 500px;
  9. }
  10. </style>
  11.  
  12. <!-- Resources -->
  13. <script src="https://www.amcharts.com/lib/3/amcharts.js"></script>
  14. <script src="https://www.amcharts.com/lib/3/serial.js"></script>
  15. <script src="https://www.amcharts.com/lib/3/amstock.js"></script>
  16. <script src="https://www.amcharts.com/lib/3/plugins/export/export.min.js"></script>
  17. <link rel="stylesheet" href="https://www.amcharts.com/lib/3/plugins/export/export.css" type="text/css" media="all" />
  18. <script src="https://www.amcharts.com/lib/3/themes/light.js"></script>
  19.  
  20. <!-- Chart code -->
  21. <script>
  22. var chartData1 = [];
  23. var chartData2 = [];
  24. var chartData3 = [];
  25. var chartData4 = [];
  26.  
  27. generateChartData();
  28.  
  29. function generateChartData() {
  30.   var firstDate = new Date();
  31.   firstDate.setDate( firstDate.getDate() - 500 );
  32.   firstDate.setHours( 0, 0, 0, 0 );
  33.  
  34.   for ( var i = 0; i < 500; i++ ) {
  35.    var newDate = new Date( firstDate );
  36.    newDate.setDate( newDate.getDate() + i );
  37.  
  38.    var a1 = Math.round( Math.random() * ( 40 + i ) ) + 100 + i;
  39.    var b1 = Math.round( Math.random() * ( 1000 + i ) ) + 500 + i * 2;
  40.  
  41.    var a2 = Math.round( Math.random() * ( 100 + i ) ) + 200 + i;
  42.    var b2 = Math.round( Math.random() * ( 1000 + i ) ) + 600 + i * 2;
  43.  
  44.    var a3 = Math.round( Math.random() * ( 100 + i ) ) + 200;
  45.    var b3 = Math.round( Math.random() * ( 1000 + i ) ) + 600 + i * 2;
  46.  
  47.    var a4 = Math.round( Math.random() * ( 100 + i ) ) + 200 + i;
  48.    var b4 = Math.round( Math.random() * ( 100 + i ) ) + 600 + i;
  49.  
  50.    chartData1.push( {
  51.      "date": newDate,
  52.      "value": a1,
  53.      "volume": b1
  54.    } );
  55.    chartData2.push( {
  56.      "date": newDate,
  57.      "value": a2,
  58.      "volume": b2
  59.    } );
  60.    chartData3.push( {
  61.      "date": newDate,
  62.      "value": a3,
  63.      "volume": b3
  64.    } );
  65.    chartData4.push( {
  66.      "date": newDate,
  67.      "value": a4,
  68.      "volume": b4
  69.    } );
  70.  }
  71. }
  72.  
  73. var chart = AmCharts.makeChart( "chartdiv", {
  74.  "type": "stock",
  75.  "theme": "light",
  76.  "dataSets": [ {
  77.      "title": "first data set",
  78.      "fieldMappings": [ {
  79.        "fromField": "value",
  80.        "toField": "value"
  81.      }, {
  82.        "fromField": "volume",
  83.        "toField": "volume"
  84.      } ],
  85.      "dataProvider": chartData1,
  86.      "categoryField": "date"
  87.    }, {
  88.      "title": "second data set",
  89.      "fieldMappings": [ {
  90.        "fromField": "value",
  91.        "toField": "value"
  92.      }, {
  93.        "fromField": "volume",
  94.        "toField": "volume"
  95.      } ],
  96.      "dataProvider": chartData2,
  97.      "categoryField": "date"
  98.    }, {
  99.      "title": "third data set",
  100.      "fieldMappings": [ {
  101.        "fromField": "value",
  102.        "toField": "value"
  103.      }, {
  104.        "fromField": "volume",
  105.        "toField": "volume"
  106.      } ],
  107.      "dataProvider": chartData3,
  108.      "categoryField": "date"
  109.    }, {
  110.      "title": "fourth data set",
  111.      "fieldMappings": [ {
  112.        "fromField": "value",
  113.        "toField": "value"
  114.      }, {
  115.        "fromField": "volume",
  116.        "toField": "volume"
  117.      } ],
  118.      "dataProvider": chartData4,
  119.      "categoryField": "date"
  120.    }
  121.  ],
  122.  
  123.  "panels": [ {
  124.    "showCategoryAxis": false,
  125.    "title": "Value",
  126.    "percentHeight": 70,
  127.    "stockGraphs": [ {
  128.      "id": "g1",
  129.      "valueField": "value",
  130.      "comparable": true,
  131.      "compareField": "value",
  132.      "balloonText": "[[title]]:<b>[[value]]</b>",
  133.       "compareGraphBalloonText": "[[title]]:<b>[[value]]</b>"
  134.     } ],
  135.     "stockLegend": {
  136.       "periodValueTextComparing": "[[percents.value.close]]%",
  137.       "periodValueTextRegular": "[[value.close]]"
  138.     }
  139.   }, {
  140.     "title": "Volume",
  141.     "percentHeight": 30,
  142.     "stockGraphs": [ {
  143.       "valueField": "volume",
  144.       "type": "column",
  145.       "showBalloon": false,
  146.       "fillAlphas": 1
  147.     } ],
  148.     "stockLegend": {
  149.       "periodValueTextRegular": "[[value.close]]"
  150.     }
  151.   } ],
  152.  
  153.   "chartScrollbarSettings": {
  154.     "graph": "g1"
  155.   },
  156.  
  157.   "chartCursorSettings": {
  158.     "valueBalloonsEnabled": true,
  159.     "fullWidth": true,
  160.     "cursorAlpha": 0.1,
  161.     "valueLineBalloonEnabled": true,
  162.     "valueLineEnabled": true,
  163.     "valueLineAlpha": 0.5
  164.   },
  165.  
  166.   "periodSelector": {
  167.     "position": "left",
  168.     "periods": [ {
  169.       "period": "MM",
  170.       "selected": true,
  171.       "count": 1,
  172.       "label": "1 month"
  173.     }, {
  174.       "period": "YYYY",
  175.       "count": 1,
  176.       "label": "1 year"
  177.     }, {
  178.       "period": "YTD",
  179.       "label": "YTD"
  180.     }, {
  181.       "period": "MAX",
  182.       "label": "MAX"
  183.     } ]
  184.   },
  185.  
  186.   "dataSetSelector": {
  187.     "position": "left"
  188.   },
  189.  
  190.   "export": {
  191.     "enabled": true
  192.   }
  193. } );
  194. </script>
  195.  
  196. <!-- HTML -->
  197. <div id="chartdiv"></div>
  198. </body>
Advertisement
Add Comment
Please, Sign In to add comment