自定义素面图 [英] Customize primefaces chart

查看:27
本文介绍了自定义素面图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的项目中使用了 primefaces 的图表.

I using of primefaces's chart on my project.

我知道是 primefaces 的 jqplot 图表使用.

I know be primefaces's chart use of jqplot .

在 jqplot 的站点上存在自定义 jqplot 图表的示例.

on jqplot's site exist example of customizing jqplot chart.

如何使用示例代码自定义素面图?

how to use of example codes for customizing primefaces chart ?

自定义jqplot图表的示例代码如下:

sample code for customizing jqplot chart is following :

$(document).ready(function () {
$.jqplot._noToImageButton = true;
var plot1 = $.jqplot("chart1", [prevYear, currYear], {
    seriesColors: ["rgba(78, 135, 194, 0.7)", "rgb(211, 235, 59)"],
    title: 'Monthly TurnKey Revenue',
    highlighter: {
        show: true,
        sizeAdjust: 1,
        tooltipOffset: 9
    },
    grid: {
        background: 'rgba(57,57,57,0.0)',
        drawBorder: false,
        shadow: false,
        gridLineColor: '#666666',
        gridLineWidth: 2
    },
    legend: {
        show: true,
        placement: 'outside'
    },
    seriesDefaults: {
        rendererOptions: {
            smooth: true,
            animation: {
                show: true
            }
        },
        showMarker: false
    },
    series: [
        {
            fill: true,
            label: '2010'
        },
        {
            label: '2011'
        }
    ],
    axesDefaults: {
        rendererOptions: {
            baselineWidth: 1.5,
            baselineColor: '#444444',
            drawBaseline: false
        }
    },
    axes: {
        xaxis: {
            renderer: $.jqplot.DateAxisRenderer,
            tickRenderer: $.jqplot.CanvasAxisTickRenderer,
            tickOptions: {
                formatString: "%b %e",
                angle: -30,
                textColor: '#dddddd'
            },
            min: "2011-08-01",
            max: "2011-09-30",
            tickInterval: "7 days",
            drawMajorGridlines: false
        },
        yaxis: {
            renderer: $.jqplot.LogAxisRenderer,
            pad: 0,
            rendererOptions: {
                minorTicks: 1
            },
            tickOptions: {
                formatString: "$%'d",
                showMark: false
            }
        }
    }
});

  $('.jqplot-highlighter-tooltip').addClass('ui-corner-all')
});

示例链接 1

如何在素面图上使用上述代码?

how to use of above code on primefaces chart ?

推荐答案

当你使用extender时,你可以通过js改变一切.

When you use extender you can change everything by js.

这是一个例子

<p:lineChart ... extender="chartExtender"/>

并在js文件或标签下的页面中:

And on js file or in the page under Tag:

function chartExtender() {        
 // this = chart widget instance        
 // this.cfg = options        
 this.cfg.grid = {             
        background: 'transparent',
         gridLineColor: '#303030',
         drawBorder: false,
    };
  }

这只是一个例子.. 这将帮助您完成剩下的工作.

This is just an example.. This will help you to do the rest.

有关最新的 PF 版本,请查看 PrimeFaces 5.2 及更高版本中图表扩展器属性的替代方案是什么希望有帮助:)

For more recent PF versions, check What is the alternative for the chart extender attribute in PrimeFaces 5.2 and newer Hope that helps :)

这篇关于自定义素面图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆