Amcharts在气球中添加欧元符号值

时间:2016-07-14 10:13:29

标签: amcharts

这是我的Json回复,我无法弄清楚如何将Euro符号添加到我的值中。当然,这是一个响应的概念,而不是正在发送的实际数组。

{"graphAxis":[{"valueAxis":"v0","lineColor":"#00969e","bullet":"round","bulletBorderAlpha":1,"bulletSize":"8","bulletBorderThickness":1,"bulletColor":"#FFFFFF","lineThickness":"2","hideBulletsCount":"50","title":"Prolongatie brandstoftermijn","valueField":"Prolongatie brandstoftermijn","costTypeId":15,"useLineColorForBulletBorder":true}],"dataProvider":[{"Prolongatie brandstoftermijn":4163.82,"date":"2016-01-01"},{"Prolongatie brandstoftermijn":7297.77,"date":"2016-02-01"},{"Prolongatie brandstoftermijn":7297.77,"date":"2016-03-01"},{"Prolongatie brandstoftermijn":162.43,"date":"2016-04-01"}]}

任何人都可以提供有关如何将Eur符号添加到气球文本的任何输入

这是我在js文件中的代码

//ajax request to show graph
    $("#diaplayGraph").click(function(event) {      

        event.preventDefault();     
        $.ajax
        ({ 
            url: $("#frmCostViewGraph").attr('action'),
            data: $("#frmCostViewGraph").serialize(),
            type: 'post',
            beforeSend: function( xhr ) {
                var message  = '';
                var selectedCostAllocations = $("#costAllocations").val();
                var selectedCostTypes = $("#costTypes").val(); 

                if(selectedCostAllocations == null) {

                    errorMessage($("#costAllocationError").html());                 
                    return false;
                }

                if(selectedCostTypes == null) {

                    errorMessage($("#costTypeError").html());
                    return false;
                }

                if($('input[name=reportType]:checked').length<=0)
                {
                    errorMessage($("#reportTypeError").html());                 
                    return false
                }

                showLoading();
            },  

            dataType:"JSON",
            success: function(result)
            {

                hideMessage();
                chartData = result.dataProvider;
                graphAxis = result.graphAxis;

                if(chartData == '') {

                    $("#chartdiv").html($("#noRecordFound").html());
                    hideLoading();
                    return false;
                }


                var chart = AmCharts.makeChart("chartdiv", {
                    "fontFamily": "Helvetica Neue,Helvetica,Arial,Open Sans,sans-serif",                    
                    "fontSize":12,
                    "type": "serial",
                    "theme": "default",      
                    "mouseWheelZoomEnabled":true,
                    "dataDateFormat": "YYYY-MM-DD",
                    "valueAxes": [{
                        "id": "v1",
                        "axisAlpha": 0,
                        "position": "left",
                        "ignoreAxisWidth":true
                    }],
                    "balloon": {
                        "borderThickness": 1,
                        "shadowAlpha": 0
                    },
                    "legend": {
                    "useGraphSettings": false,
                    },
                "dataProvider": chartData,
                "graphs":graphAxis,
                "chartScrollbar": {
                    "graph": "g1",
                    "oppositeAxis":false,
                    "offset":30,
                    "scrollbarHeight": 20,
                    "backgroundAlpha": 0,
                    "selectedBackgroundAlpha": 0.1,
                    "selectedBackgroundColor": "#888888",
                    "graphFillAlpha": 0,
                    "graphLineAlpha": 0.5,
                    "selectedGraphFillAlpha": 0,
                    "selectedGraphLineAlpha": 1,
                    "autoGridCount":true,
                    "color":"#AAAAAA",
                    "autoGridCount": true,
                    "resizeEnabled":true
                },
                "chartCursor": {                    
                    "valueLineEnabled": true,
                    "valueLineBalloonEnabled": true,
                    "cursorAlpha":1,
                    "cursorColor":"#258cbb",
                    "limitToGraph":"g1",
                    "valueLineAlpha":0.2,
                    "valueZoomable":true,
                    "cursorPosition": "mouse",
                    "oneBalloonOnly": true,
                    "categoryBalloonDateFormat": "DD-MMM-YYYY"
                },
                "valueScrollbar":{
                    "oppositeAxis":false,
                    "offset":75,
                    "scrollbarHeight":10,
                    "backgroundAlpha":1,                    
                },
                "valueAxes": [{                 
                    "axisColor": "#23272D",                 
                    "axisAlpha": 1,
                    "position": "left",
                    "unit": "$",
                    "unitPosition": "left"
                }],             
                "categoryField": "date",
                "categoryAxis": {
                    "parseDates": true,
                    "dashLength": 1,
                    "minorGridEnabled": true,
                    "minPeriod":"MM",   
                    "axisColor": "#23272D"
                },
                "export": {
                    "enabled": true,
                },
                "numberFormatter": {
                    "precision": -1,
                    "decimalSeparator": ",",
                    "thousandsSeparator": "."
                },
            });


            chart.addListener("clickGraphItem", handleClick);

            zoomChart();

            function zoomChart() {
                chart.zoomToIndexes(chart.dataProvider.length - 40, chart.dataProvider.length - 1);
            } 

            hideLoading();          
            }
        });
    })

1 个答案:

答案 0 :(得分:0)

这应该使用graphs中的graphAxis数组来完成。

例如,如果你有这样的图表实现,你可以将欧元符号添加到balloonText属性:

 success: function(result)  {

     hideMessage();
     chartData = result.dataProvider;
     graphAxis = result.graphAxis;
     if(graphAxis && graphAxis[0]) {
         graphAxis[0].balloonText = "<b>€ [[Prolongatie brandstoftermijn]]</b>";
     }
     //...
 }