首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > Ajax >

给highcharts坐标设值有关问题

2013-01-22 
给highcharts坐标设值问题$(function () {var chart new Highcharts.Chart({chart: {renderTo: contain

给highcharts坐标设值问题


$(function () {
        var chart = new Highcharts.Chart({
            chart: {
                renderTo: 'container3',
                plotBorderWidth: 1,
                zoomx:true,
                type: 'line'
            },
            title: {
                text: null
            },
            credits:{
                enabled:false,
                position: {
                    align: 'left',
                    x: 350,
                    verticalAlign: 'bottom'
                }
            },
            legend: {
                enabled:true

            },

            xAxis: {
                type: 'datetime',
                min:minDate,  //0表示1月 以此类推
                max:maxDate,
                tickInterval :30*24*3600*1000,//X轴点间隔
                labels: {
                    align: 'left',
                    formatter: function() {
                        return Highcharts.dateFormat('%Y%m%d', this.value);
                    }
                }
            },
            yAxis:  [
                {


                    lineWidth:1,
                  //  gridLineColor: 'red',
                    gridLineDashStyle: 'shortdash',
                    max:maxYield*100,
                    min:-maxYield*100,
                    opposite: true,
                    tickInterval:(maxYield*100/3),
                    title: {
                        text: null
                    },
                    labels: {
                        formatter: function() {
                            return this.value +'%';
                        }
                    }
                },
                {
                    lineWidth:1,
                   // gridLineColor: 'red',
                    gridLineDashStyle: 'shortdash',
                    max:1500,
                    min:-1500,
                    //opposite: true,
                    //tickInterval:500,
                    title: {
                        text: null
                    },
                    labels: {


                        formatter: function() {
                            return this.value ;
                        }
                    }
                }
               ],
            tooltip: {
                formatter: function() {
                    return   this.series.name+'<br/><strong>日期:</strong>'+
                            Highcharts.dateFormat('%Y%m%d', this.x) +'<strong>收益率:</strong> '+ this.y+'%' ;
                }
            },
            plotOptions: {
                line: {
                    dataGrouping: {
                        enabled: false
                    }
                },
                series: {
                    lineWidth:1,
                    marker: {
                        radius: 1 //鼠标接触时 显示点的大小
                    }

                }

            },
            series: strategys

        });
    });



这是我的highchart代码 生成的图片如下
给highcharts坐标设值有关问题

问题: 1.我想给Y轴显示0的地方初始化一个数值
       2.Y轴正数的颜色是红的,负数颜色是绿的
 
[解决办法]
1.我想给Y轴显示0的地方初始化一个数值


不是特别理解,是想在0做个分割线吗?如果是:


yAxis: {
            plotLines: [{ 
                width: 2,
                value: 0,
                id: 'plotline-1'
            }]
        },


 2.Y轴正数的颜色是红的,负数颜色是绿的

yAxis:  [
                {
                    lineWidth:1,
                  //  gridLineColor: 'red',
                    gridLineDashStyle: 'shortdash',
                    max:maxYield*100,
                    min:-maxYield*100,
                    opposite: true,
                    tickInterval:(maxYield*100/3),
                    title: {
                        text: null
                    },
                    labels: {
                        formatter: function() {
                            //注意改的是这里!!!!!!
                            if (this.value >0) {
                                return '<span style="fill: red;">' + this.value +'%'; + '</span>';
                            else if(this.value <0){
                                return '<span style="fill: green;">' + this.value +'%'; + '</span>';
                            } else {


                                return this.value +'%';
                            }
                        }
                    }
                },
                {
                    lineWidth:1,
                   // gridLineColor: 'red',
                    gridLineDashStyle: 'shortdash',
                    max:1500,
                    min:-1500,
                    //opposite: true,
                    //tickInterval:500,
                    title: {
                        text: null
                    },
                    labels: {
                        formatter: function() {
                            //注意改的是这里!!!!!!
                            if (this.value >0) {
                                return '<span style="fill: red;">' + this.value; + '</span>';
                            else if(this.value <0){
                                return '<span style="fill: green;">' + this.value; + '</span>';
                            } else {


                                return this.value;
                            }
                        }
                    }
                }
               ],


热点排行