Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // block-ac-profit
- (function() {
- var btn = $('.jsCbtn');
- btn.click(function(event) {
- btn.removeClass('active');
- $(this).addClass('active');
- });
- if($('div').is('.block-ac-profit')) {
- profitChrat();
- }
- function profitChrat() {
- $.getJSON('/en/ajax/graph=graphstat', function(chartData) {
- var chart = AmCharts.makeChart("profitChart", {
- "type": "serial",
- "theme": "light",
- "marginRight": 40,
- "marginLeft": 0,
- "autoMarginOffset": 0,
- "mouseWheelZoomEnabled":true,
- "dataDateFormat": "YYYY-MM-DD",
- "valueAxes": [{
- "axisAlpha": 0,
- "dashLength": 3,
- "gridAlpha": 0.16,
- "gridCount": 0,
- "id": "v1",
- "position": "right",
- "ignoreAxisWidth":true
- }],
- "balloon": {
- "borderThickness": 1,
- "shadowAlpha": 0
- },
- "graphs": [{
- "balloonText":"≈[[value]]%",
- "id": "g1",
- "bullet": "round",
- "bulletBorderAlpha": 1,
- "bulletColor": "#FFFFFF",
- "bulletSize": 5,
- "hideBulletsCount": 50,
- "lineThickness": 2,
- "title": "red line",
- "useLineColorForBulletBorder": true,
- "valueField": "value"
- //"balloonText": "<span style='font-size:18px;'>[[value]]</span>"
- }],
- "chartScrollbar": {
- "graph": "g1",
- "oppositeAxis":false,
- "offset":30,
- "scrollbarHeight": 80,
- "backgroundAlpha": 0,
- "selectedBackgroundAlpha": 0.1,
- "selectedBackgroundColor": "#888888",
- "graphFillAlpha": 0,
- "graphLineAlpha": 0.5,
- "selectedGraphFillAlpha": 0,
- "selectedGraphLineAlpha": 1,
- "autoGridCount":true,
- "color":"#AAAAAA"
- },
- "chartCursor": {
- "pan": true,
- "valueLineEnabled": true,
- "valueLineBalloonEnabled": true,
- "cursorAlpha":1,
- "cursorColor":"#258cbb",
- "limitToGraph":"g1",
- "valueLineAlpha":0.2,
- "valueZoomable":true
- },
- "categoryField": "month",
- "categoryAxis": {
- "parseDates": true,
- "dashLength": 1,
- "minorGridEnabled": true,
- "gridAlpha": 0,
- "minorGridAlpha": 0,
- "tickLength": 0,
- "axisAlpha": 0.16
- },
- "export": {
- "enabled": false
- },
- "dataProvider": chartData,
- "zoomOutOnDataUpdate": false
- });
- chart.addListener("rendered", zoomChart);
- zoomChart();
- function zoomChart() {
- chart.zoomToIndexes(chart.dataProvider.length - 40, chart.dataProvider.length - 1);
- }
- function getYearlyData( monthly ) {
- var yearly = [];
- for ( var i = 0; i < monthly.length; i++ ) {
- var dp = monthly[ i ],
- next = monthly[ i + 1 ];
- if ( next === undefined || dp.month.split('-')[0] != next.month.split('-')[0] )
- yearly.push( dp );
- }
- return yearly;
- }
- function setData(type) {
- if ( type == "monthly" ) {
- chart.dataProvider = chartData;
- chart.categoryAxis.minPeriod = "MM";
- chart.chartCursor.categoryBalloonDateFormat = "MM";
- }
- else if( type == "yearly" ) {
- chart.dataProvider = getYearlyData( chartData );
- chart.categoryAxis.minPeriod = "YYYY";
- chart.chartCursor.categoryBalloonDateFormat = "YYYY";
- }
- chart.validateData();
- };
- $( ".year" ).click(function() {
- setData("yearly");
- });
- $( ".1month" ).click(function() {
- setData("monthly");
- });
- });
- }
- })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement