Highcharts如何使y轴系列值仅返回2位小数

时间:2016-08-04 03:39:11

标签: javascript highcharts

enter image description here

我想让y轴系列的格式只返回2位小数。

我有这段代码:

NSString *path = [[NSBundle mainBundle] pathForResource:@"data.docx" ofType:nil];
NSURL *url = [NSURL fileURLWithPath:path];
NSData *data = [NSData dataWithContentsOfFile:path];
[self.webview loadData:data MIMEType:@"application/vnd.openxmlformats-officedocument.wordprocessingml.document" textEncodingName:@"UTF-8" baseURL:url];

我尝试添加以下代码:

$('#main-graph').highcharts({
        chart:{
            zoomType:'xy',
            type: 'spline'
        },
        title: {
            text: '',
            x: -20 //center
        },
        xAxis: {
            categories: stat_date,
            crosshair:true,
        },
        yAxis: [
        { //0
            title: {
                text: 'Impressions'
            },
        },
        {//1
            title:{
                text: "Clicks"
            }
        },
        { //2
            title:{
                text: "CTR"
            }
        },
        { //3
            title:{
                text: "CPM"
            }
        },
        { //4
            title:{
                text: "CPC"
            }
        },
        { //5 - secondary axis which is the SPEND axis
            title: {
                text: "Spend",
                style:{
                     // color: Highcharts.getOptions().colors[0]
                     color: "#8B8B8B"
                }
            },
            opposite:true
        }],
        tooltip: {
            shared: true,
            valueDecimals: 2
            // pointFormat: "{point.y:,.2f}"
        },
        legend: {
            layout: 'horizontal',
            align: 'top',
            verticalAlign: 'top',
            borderWidth: 0,
            floating:true,
            x: 0,
            y: 0
        },
        series: [{
            name: 'Spend',
            data: spend,
            yAxis: 5,
            type:'column'
        }, {
            name: 'Impressions',
            data: imp,
            yAxis: 0,
        }, {
            name: 'Clicks',
            data: clicks,
            yAxis: 1
        },
        {
            name: 'CTR',
            data: ctr,
            yAxis: 2
        }, {
            name: 'CPM',
            data: cpm,
            yAxis: 3
        }, {
            name: 'CPC',
            data: cpc,
            yAxis: 4
        }
        ]
    });
}

但它不起作用。

有什么想法吗?你的帮助将是贪得无厌的!

谢谢!

0 个答案:

没有答案