jQuery   发布时间:2022-03-30  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了jquery – jqplot,删除外边框大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
如何删除jqplot的外边框,请看下面的截图.
我尝试了不同的选项并搜索它,但我没有得到解决方案.

这是我的代码,

plot1 = $.jqplot(container,[data],{
        title: 'title',animate: true,animateReplot: true,seriesColors:['#00ADEE'],seriesDefaults: {
            renderer: $.jqplot.BarRenderer,shadow: false
        },axesDefaults: {
        },Highlighter: {
            tooltipAxes: 'y',show: true,tooltipLocation: 'sw',formatString: '<table class="jqplot-Highlighter"> \
      <tr><td>test:</td><td>%s</td></tr></table>'
        },grid: {borderColor: 'transparent',shadow: false,drawBorder: false,shadowColor: 'transparent'},axes: {
            xaxis: {
                renderer: $.jqplot.CategoryAxisRenderer,ticks:ticks
            },yaxis: {
                max:1000
            }
        }
    });

请帮帮我.提前致谢.

这是Jsfiddle link,我想删除外边框.

解决方法

您可以在 postDrawHooks注册自定义函数,在插件初始化后触发.

我们的想法是使用此功能在图表顶部绘制一个白色边框矩形,使外边框不可见.

$.jqplot.postDrawHooks.push(function() {
    var $canvasMain = $("#chart1 canvas.jqplot-grid-canvas"),$canvasLines = $("#chart1 canvas.jqplot-series-canvas"),canvasSize = { 
            x: parseInt($canvasLines.attr('width')),y: parseInt($canvasLines.attr('height'))
        },ctx = $canvasMain[0].getContext('2d');

    ctx.strokeStyle = 'white';
    ctx.lineWidth = 6; // 6 to hide shadows and the larger bottom side
    ctx.rect($canvasLines.position().left,$canvasLines.position().top,canvasSize.x,canvasSize.y + 3);
    ctx.stroke();    
});

jsFiddle

你可以看到外边界消失了:

这工作正常,但我个人会继续修改源以跳过外部边界.该插件使用GPLv2和MIT双重许可,所以我想这条路线没有问题.

解决方案2

我发现如果你改变这个

grid: {borderColor: 'transparent',

grid: {borderColor: 'white',drawBorder: true},

外边框消失了(我上面做的那种),但是x轴上仍然会出现一些刻度线.我设置了showTickMarks:false表示没有成功.

jsFiddle

大佬总结

以上是大佬教程为你收集整理的jquery – jqplot,删除外边框全部内容,希望文章能够帮你解决jquery – jqplot,删除外边框所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。
标签: