Javascript 带角度的海图,删除X轴线

Javascript 带角度的海图,删除X轴线,javascript,angularjs,highcharts,Javascript,Angularjs,Highcharts,我正在使用highcharts,我已经制定了一个名为sparkLine的指令 代码如下: chartModule.directive('sparkLine', function () { return { restrict: 'E', scope: { series: '=', lineName: '=', lineTooltip: '=', xAxisEnabled: '=', yAxisEnabl

我正在使用highcharts,我已经制定了一个名为sparkLine的指令 代码如下:

chartModule.directive('sparkLine', function () {
return {
    restrict: 'E',
    scope: {
        series: '=',
        lineName: '=',
        lineTooltip: '=',
        xAxisEnabled: '=',
        yAxisEnabled: '=',
        lineColor: '='
    },
    replace: true,
    template: '<div></div>',

    link: function (scope, element, attrs) {

        var xEnable = (typeof (attrs.xAxisEnabled) == 'undefined') ? false : true;
        var yEnable = (typeof (attrs.yAxisEnabled) == 'undefined') ? false : true;
        var lColor = (typeof (attrs.lineColor) == 'undefined') ? '#808080' : lineColor;

        $(element).highcharts({
            chart:
            {
                type: 'line',
                width: attrs.width,
                height: attrs.height,
                backgroundColor: attrs.backgroundColor
            },
            title: {
                text: ''
            },
            plotOptions: {
                series: {
                    marker: {
                        radius: (typeof (attrs.pointRadius) == 'undefined') ? 2 : attrs.pointRadius,
                    }
                }
            },
            navigation: {
                buttonOptions: {
                    enabled: false
                }
            },
            credits: {
                enabled: false
            },

            xAxis: {
                lineColor: 'transparent',
                tickWidth: 0,
                lineHeight: 0,
                labels: {
                    enabled: xEnable
                },
                categories: []
            },
            yAxis: {
                lineColor: 'transparent',
                gridLineColor: 'trasparent',
                title: {
                    text: ''
                },
                labels: {
                    enabled: yEnable
                },
                plotLines: [{
                    value: 0,
                    width: 1,
                    color: lColor
                }]
            },
            tooltip: {
                formatter:
                    function () {
                        return scope.lineTooltip(this.x, scope.lineName, this.y.toLocaleString());
                    },
                hideDelay: 50
            },
            legend: {
                enabled: false
            },
            series: [{
                name: '',
                data: []
            }]
        });

        scope.$watch('series', function () {
            var chart = $(element).highcharts();
            scope.newperiodsTrends = [];
            scope.categoriesPeriods = [];
            angular.forEach(scope.series, function (elm, index) {
                scope.newperiodsTrends.push(elm.Value);
                scope.categoriesPeriods.push(elm.IterationName);
            });

            chart.series[0].setData(scope.newperiodsTrends);
            chart.xAxis[0].setCategories(scope.categoriesPeriods);
        });
    }
}
chartModule.directive('sparkLine',function(){
返回{
限制:'E',
范围:{
系列:'=',
lineName:“=”,
lineTooltip:“=”,
xAxisEnabled:“=”,
yAxisEnabled:“=”,
线条颜色:'='
},
替换:正确,
模板:“”,
链接:函数(范围、元素、属性){
var xEnable=(typeof(attrs.xaxisaenabled)=‘未定义’?false:true;
var yEnable=(typeof(attrs.yaxisabled)==“undefined”)?false:true;
var lColor=(typeof(attrs.lineColor)=‘未定义’?‘808080’:lineColor;
$(元素).highcharts({
图表:
{
键入:“行”,
宽度:attrs.width,
高度:attrs.height,
背景颜色:attrs.backgroundColor
},
标题:{
文本:“”
},
打印选项:{
系列:{
标记:{
半径:(typeof(attrs.pointRadius)=‘未定义’?2:attrs.pointRadius,
}
}
},
导航:{
按钮选项:{
已启用:false
}
},
学分:{
已启用:false
},
xAxis:{
lineColor:'透明',
宽度:0,
线宽:0,
标签:{
已启用:xEnable
},
类别:[]
},
亚克斯:{
lineColor:'透明',
gridLineColor:“trasparent”,
标题:{
文本:“”
},
标签:{
启用:可启用
},
绘图线:[{
值:0,
宽度:1,
颜色:lColor
}]
},
工具提示:{
格式化程序:
函数(){
返回scope.lineTooltip(this.x,scope.lineName,this.y.toLocaleString());
},
希德雷:50
},
图例:{
已启用:false
},
系列:[{
名称:“”,
数据:[]
}]
});
范围:$watch('系列',功能(){
var chart=$(元素).highcharts();
scope.newperiodsTrends=[];
scope.categoriesPeriods=[];
角度.forEach(scope.series,function(elm,index){
范围.newperiodsTrends.push(elm.Value);
scope.categoriesPeriods.push(elm.IterationName);
});
chart.series[0].setData(scope.newperiods);
chart.xAxis[0].setCategories(scope.categoriesPeriods);
});
}
}
}))

我的代码中此指令的用法是:

 <spark-line series="dataSeries" line-tooltip="tooltip" line-name="'Value'" class="sparkLine">

在我的html代码中,我使用angularjs,并使用ng repeat创建了一个表:

我的问题是,我无法从其中一个图中删除xAxis

编辑: 我发现了问题: 当我删除css文件中包含的高度和宽度时(class=“sparkLine”) 这条线被删除了可能是highchart的小故障。。。 如果有解决办法,我很想听听
感谢

对于Highcharts,您可以使用axis.remove-删除axis

如果您想从视图中隐藏它,那么您的操作是正确的,如果

xAxis: {
   ...  
   lineWidth: 0,
   minorGridLineWidth: 0,
   lineColor: 'transparent',
   ...          
   labels: {
       enabled: false
   },
   minorTickLength: 0,
   tickLength: 0
}


例如,JSFIDLE将非常有助于确定不需要的灰线的原点。

您可以为此添加plunker吗?我不知道如何添加它,它被放置在一个大项目中,需要花费我很多时间来设置它谢谢您的回答,但问题是另一个图形的X轴线没有显示。。。给我带来麻烦的1图数据更改可能太远了。因此,结果显示了底线(我测试了它)