Javascript 拉斐尔折线图轴线标签与轴线重叠

Javascript 拉斐尔折线图轴线标签与轴线重叠,javascript,raphael,linechart,axis-labels,Javascript,Raphael,Linechart,Axis Labels,为折线图轴打印自定义标签时,标签旋转时,标签文本与轴重叠。如何解决这个问题??我尝试搜索文档并找到元素。transform()用于旋转,而不是rotate(),因为它已贬值,但我无法使它工作。 有人能帮忙吗 var lines1 = r.linechart(100, 50, 950, 470, x, y, { smooth : false,

为折线图轴打印自定义标签时,标签旋转时,标签文本与轴重叠。如何解决这个问题??我尝试搜索文档并找到元素。transform()用于旋转,而不是rotate(),因为它已贬值,但我无法使它工作。 有人能帮忙吗

   var lines1 = r.linechart(100, 50, 950, 470, x,
                             y, {
                                smooth : false,
                                symbol : 'circle',
                                axis : "0 0 1 1",
                                axisxstep: 20,
                                axisystep:20
                            }).hoverColumn(function () {
                                this.tags = r.set();
                                     for (var i = 0, ii = this.y.length; i < ii; i++) {
                                            this.tags.push(r.tag(this.x, this.y[i], this.values[i], 160, 5).insertBefore(this).attr([{ fill: "#fff" }, { fill: this.symbols[i].attr("fill") }]));
                                        }
                                    }, function () {
                                        this.tags && this.tags.remove();
                                    }); 

                         var axisItems = lines1.axis[0].text.items
                        for( var i = 0, l = axisItems.length; i < l; i++ ) {
                           var date = new Date(parseInt(axisItems[i].attr("text")));
                           axisItems[i].rotate(270,this.x ,this.y);
                           axisItems[i].attr("text", dateFormat(date, "dmmm,htt")); 
                        } 

不确定你是否还需要这个。。。但我最终编写了自己的标签函数

if (props.label !== undefined) {
    // don't use the default Raphael label() function, is broken
    chart.customLabel = customLabelFn;
    chart.customLabel(props.label);
}
customLabelFn是我绘制标签的方式,这是我的垂直条形图的一个示例:

customLabelFn = function (labels) {
    var x, y;
    labels = labels || [];

    for (var i = 0; i < props.bars.length; i++) {
        x = props.bars[i].x;
        y = props.bars[i].y + props.bars[i].h + props.xaxisLabelOffset;
        props.r.text(x, y, labels[i]);
    }
    return this;
};
它对我很有用,我可以在其他任何地方访问这些条,因此我可以使用它们在条、标签等顶部绘制数字


希望有此帮助。

在您的
中,循环使用:
axisItems[i].翻译(0,30)

我还建议你旋转90而不是270,这样文本将向下延伸而不是向上延伸

// immediately calls the function so that we can have all the rendered bars
chart.getBars = function() {
    props.bars = (props.stacked ?
        this.bars[0] : // pick the one and only bar
        this.bars);
};
chart.getBars();