JFreeChart Coldfusion拨号表

JFreeChart Coldfusion拨号表,coldfusion,jfreechart,coldfusion-7,Coldfusion,Jfreechart,Coldfusion 7,有人举过在Coldfusion上实现JFreechart拨号表的例子吗 感谢该软件包提供了如何构建一些基本图表的示例;单击类名以查看源代码。这些方法还进一步说明了如何构造。该类包括多种格式的流式图表的方法。相应的response.setContentType()可以从任何servlet容器中工作 如果这是无名地,我建议† †免责声明:不隶属于Object Refinery Limited;仅仅是一个满意的客户和一个很小的贡献者。该软件包提供了如何构建一些基本图表的示例;单击类名以查看源代码。这些

有人举过在Coldfusion上实现JFreechart拨号表的例子吗

感谢

该软件包提供了如何构建一些基本图表的示例;单击类名以查看源代码。这些方法还进一步说明了如何构造。该类包括多种格式的流式图表的方法。相应的
response.setContentType()
可以从任何servlet容器中工作

如果这是无名地,我建议†

†免责声明:不隶属于Object Refinery Limited;仅仅是一个满意的客户和一个很小的贡献者。

该软件包提供了如何构建一些基本图表的示例;单击类名以查看源代码。这些方法还进一步说明了如何构造。该类包括多种格式的流式图表的方法。相应的
response.setContentType()
可以从任何servlet容器中工作

如果这是无名地,我建议†


†免责声明:不隶属于Object Refinery Limited;仅仅是一位满意的客户,贡献率很低。

根据垃圾神的建议,我为CF7创建了一个非常基本的示例。显然,你可以用它做更多的事情。只需查看api和/或购买开发者指南

安装: 下载最新的jfreeChart。将以下jar复制到
{cf_root}\WEB-INF\lib
中,然后重新启动cf。注意,jar版本号可能会有所不同

  • jfreechart-1.0.13.jar
  • jcommon-1.0.16.jar
示例:

<cfscript>
// my chart settings
chartTitle = "My Dial Chart";
arrowValue  = 55;
dialMinimum = 0;
dialMaximum = 100;
chartWidth  = 500;
chartHeight = 500;

// initialize basic components of the chart
// see jFreeChart API on how to customize the components settings further 
DefaultValueDataset = createObject("java", "org.jfree.data.general.DefaultValueDataset");
pointerValue    = DefaultValueDataset.init(arrowValue);
dialPointer     = createObject("java", "org.jfree.chart.plot.dial.DialPointer$Pointer").init();
dialFrame       = createObject("java", "org.jfree.chart.plot.dial.StandardDialFrame").init();
dialBackground  = createObject("java", "org.jfree.chart.plot.dial.DialBackground").init();
// tweak the default range to make it more appealing.
// see angle/extent: http://java.sun.com/developer/technicalArticles/GUI/java2d/java2dpart1.html
dialScale = createObject("java", "org.jfree.chart.plot.dial.StandardDialScale").init();
dialScale.setLowerBound(dialMinimum);
dialScale.setUpperBound(dialMaximum);
dialScale.setStartAngle(-150);
dialScale.setExtent(-240);

//initialize plot and apply settings
plot = createObject("java", "org.jfree.chart.plot.dial.DialPlot").init();
plot.setDialFrame(dialFrame);
plot.setBackground(dialBackground);
plot.setDataset(pointerValue);
plot.addScale(0, dialScale);
plot.addPointer(dialPointer);

// create chart and convert it to an image
chart = createObject("java", "org.jfree.chart.JFreeChart").init(chartTitle, plot);
chartImage = chart.createBufferedImage(chartWidth, chartHeight);
ImageFormat = createObject("java", "org.jfree.chart.encoders.ImageFormat");
EncoderUtil = createObject("java", "org.jfree.chart.encoders.EncoderUtil");
bytes = EncoderUtil.encode( chartImage, ImageFormat.PNG);
</cfscript>

<!--- display in browser --->
<cfcontent type="image/png" variable="#bytes#">
<cfscript>
    // my chart settings
    chartTitle = "My Meter Chart";
    arrowValue  = 55;
    arrowUnits  = "widgets";
    chartWidth  = 500;
    chartHeight = 500;

    // initialize meter ranges (LOW, MEDIUM, HIGH)
    // note: quick and ugly code in dire need of improvement ...
    low  = createSolidMeterInterval("Low", 0, 40, createAwtColor(0, 255, 0, 120));
    med  = createSolidMeterInterval("Med", 40, 60, createAwtColor(255, 255, 0, 120));
    high = createSolidMeterInterval("High", 60, 100, createAwtColor(255, 0, 0, 120));

    // initialize arrow value
    DefaultValueDataset = createObject("java", "org.jfree.data.general.DefaultValueDataset");
    meterPointer = DefaultValueDataset.init(arrowValue);

    //initialize plot and apply settings
    plot = createObject("java", "org.jfree.chart.plot.MeterPlot").init();
    plot.setDataset(meterPointer);
    plot.setTickLabelsVisible(true);
    plot.addInterval(low);
    plot.addInterval(med);
    plot.addInterval(high);
    plot.setUnits(arrowUnits);

    // create chart and convert it to an image
    chart = createObject("java", "org.jfree.chart.JFreeChart").init(chartTitle, plot);
    ChartUtilities = createObject("java", "org.jfree.chart.ChartUtilities");
    ChartUtilities.applyCurrentTheme(chart);

    // applyCurrentTheme seems to overwrite some settings, so we must reapply them 
    Color = createObject("java", "java.awt.Color");
    plot.setBackgroundPaint(Color.GRAY);
    plot.setNeedlePaint(Color.BLACK);

    chartImage = chart.createBufferedImage(chartWidth, chartHeight);
    ImageFormat = createObject("java", "org.jfree.chart.encoders.ImageFormat");
    EncoderUtil = createObject("java", "org.jfree.chart.encoders.EncoderUtil");
    bytes = EncoderUtil.encode( chartImage, ImageFormat.PNG); 
</cfscript>
<!--- display in browser --->
<cfcontent type="image/png" variable="#bytes#">
<cfscript>
        // quick and ugly functions. could be improved ...  
        function createSolidMeterInterval(Title, fromValue, toValue, BgColor) {
            var Range = createObject("java", "org.jfree.data.Range").init(arguments.fromValue, arguments.toValue);
            var MeterInterval = createObject("java", "org.jfree.chart.plot.MeterInterval");
            return MeterInterval.init(arguments.Title, Range   // interval from / to range 
                                        , javacast("null", "") // outline color
                                        , javacast("null", "") // outline stroke
                                        , arguments.BgColor    // background color
                                    );
        }


        // using java.awt.Color is a pain due to all the javacasts ...
        function createAwtColor(r, g, b, alpha) {
            var color = createObject("java", "java.awt.Color");
            return color.init( javacast("int", arguments.r)
                                , javacast("int", arguments.g)
                                , javacast("int", arguments.b)
                                , javacast("int", arguments.alpha) // transparency
                            );  
        }
</cfscript>     

//我的图表设置
chartTitle=“我的拨号表”;
箭头值=55;
最小值=0;
最大值=100;
图表宽度=500;
图表高度=500;
//初始化图表的基本组件
//有关如何进一步自定义组件设置,请参见jFreeChart API
DefaultValueDataset=createObject(“java”、“org.jfree.data.general.DefaultValueDataset”);
pointerValue=DefaultValueDataset.init(箭头值);
dialPointer=createObject(“java”、“org.jfree.chart.plot.dial.dialPointer$Pointer”).init();
dialFrame=createObject(“java”,“org.jfree.chart.plot.dial.StandardDialFrame”).init();
dialBackground=createObject(“java”,“org.jfree.chart.plot.dial.dialBackground”).init();
//调整默认范围以使其更具吸引力。
//请参见角度/范围:http://java.sun.com/developer/technicalArticles/GUI/java2d/java2dpart1.html
dialScale=createObject(“java”,“org.jfree.chart.plot.dial.StandardDialScale”).init();
dialScale.setLowerBound(拨号最小值);
dialScale.setUpperBound(拨号最大值);
刻度盘。设置起始角(-150);
dialScale.setExtent(-240);
//初始化打印并应用设置
plot=createObject(“java”,“org.jfree.chart.plot.dial.DialPlot”).init();
plot.setDialFrame(dialFrame);
情节。挫折背景(背景);
plot.setDataset(pointerValue);
plot.addScale(0,dialScale);
plot.addPointer(拨号指针);
//创建图表并将其转换为图像
chart=createObject(“java”,“org.jfree.chart.JFreeChart”).init(图表标题,绘图);
chartImage=chart.createBuffereImage(图表宽度、图表高度);
ImageFormat=createObject(“java”、“org.jfree.chart.encoders.ImageFormat”);
EncoderUtil=createObject(“java”,“org.jfree.chart.encoders.EncoderUtil”);
字节=EncoderUtil.encode(chartImage,ImageFormat.PNG);

根据垃圾神的建议,我为CF7创建了一个非常基本的示例。显然,你可以用它做更多的事情。只需查看api和/或购买开发者指南

安装: 下载最新的jfreeChart。将以下jar复制到
{cf_root}\WEB-INF\lib
中,然后重新启动cf。注意,jar版本号可能会有所不同

  • jfreechart-1.0.13.jar
  • jcommon-1.0.16.jar
示例:

<cfscript>
// my chart settings
chartTitle = "My Dial Chart";
arrowValue  = 55;
dialMinimum = 0;
dialMaximum = 100;
chartWidth  = 500;
chartHeight = 500;

// initialize basic components of the chart
// see jFreeChart API on how to customize the components settings further 
DefaultValueDataset = createObject("java", "org.jfree.data.general.DefaultValueDataset");
pointerValue    = DefaultValueDataset.init(arrowValue);
dialPointer     = createObject("java", "org.jfree.chart.plot.dial.DialPointer$Pointer").init();
dialFrame       = createObject("java", "org.jfree.chart.plot.dial.StandardDialFrame").init();
dialBackground  = createObject("java", "org.jfree.chart.plot.dial.DialBackground").init();
// tweak the default range to make it more appealing.
// see angle/extent: http://java.sun.com/developer/technicalArticles/GUI/java2d/java2dpart1.html
dialScale = createObject("java", "org.jfree.chart.plot.dial.StandardDialScale").init();
dialScale.setLowerBound(dialMinimum);
dialScale.setUpperBound(dialMaximum);
dialScale.setStartAngle(-150);
dialScale.setExtent(-240);

//initialize plot and apply settings
plot = createObject("java", "org.jfree.chart.plot.dial.DialPlot").init();
plot.setDialFrame(dialFrame);
plot.setBackground(dialBackground);
plot.setDataset(pointerValue);
plot.addScale(0, dialScale);
plot.addPointer(dialPointer);

// create chart and convert it to an image
chart = createObject("java", "org.jfree.chart.JFreeChart").init(chartTitle, plot);
chartImage = chart.createBufferedImage(chartWidth, chartHeight);
ImageFormat = createObject("java", "org.jfree.chart.encoders.ImageFormat");
EncoderUtil = createObject("java", "org.jfree.chart.encoders.EncoderUtil");
bytes = EncoderUtil.encode( chartImage, ImageFormat.PNG);
</cfscript>

<!--- display in browser --->
<cfcontent type="image/png" variable="#bytes#">
<cfscript>
    // my chart settings
    chartTitle = "My Meter Chart";
    arrowValue  = 55;
    arrowUnits  = "widgets";
    chartWidth  = 500;
    chartHeight = 500;

    // initialize meter ranges (LOW, MEDIUM, HIGH)
    // note: quick and ugly code in dire need of improvement ...
    low  = createSolidMeterInterval("Low", 0, 40, createAwtColor(0, 255, 0, 120));
    med  = createSolidMeterInterval("Med", 40, 60, createAwtColor(255, 255, 0, 120));
    high = createSolidMeterInterval("High", 60, 100, createAwtColor(255, 0, 0, 120));

    // initialize arrow value
    DefaultValueDataset = createObject("java", "org.jfree.data.general.DefaultValueDataset");
    meterPointer = DefaultValueDataset.init(arrowValue);

    //initialize plot and apply settings
    plot = createObject("java", "org.jfree.chart.plot.MeterPlot").init();
    plot.setDataset(meterPointer);
    plot.setTickLabelsVisible(true);
    plot.addInterval(low);
    plot.addInterval(med);
    plot.addInterval(high);
    plot.setUnits(arrowUnits);

    // create chart and convert it to an image
    chart = createObject("java", "org.jfree.chart.JFreeChart").init(chartTitle, plot);
    ChartUtilities = createObject("java", "org.jfree.chart.ChartUtilities");
    ChartUtilities.applyCurrentTheme(chart);

    // applyCurrentTheme seems to overwrite some settings, so we must reapply them 
    Color = createObject("java", "java.awt.Color");
    plot.setBackgroundPaint(Color.GRAY);
    plot.setNeedlePaint(Color.BLACK);

    chartImage = chart.createBufferedImage(chartWidth, chartHeight);
    ImageFormat = createObject("java", "org.jfree.chart.encoders.ImageFormat");
    EncoderUtil = createObject("java", "org.jfree.chart.encoders.EncoderUtil");
    bytes = EncoderUtil.encode( chartImage, ImageFormat.PNG); 
</cfscript>
<!--- display in browser --->
<cfcontent type="image/png" variable="#bytes#">
<cfscript>
        // quick and ugly functions. could be improved ...  
        function createSolidMeterInterval(Title, fromValue, toValue, BgColor) {
            var Range = createObject("java", "org.jfree.data.Range").init(arguments.fromValue, arguments.toValue);
            var MeterInterval = createObject("java", "org.jfree.chart.plot.MeterInterval");
            return MeterInterval.init(arguments.Title, Range   // interval from / to range 
                                        , javacast("null", "") // outline color
                                        , javacast("null", "") // outline stroke
                                        , arguments.BgColor    // background color
                                    );
        }


        // using java.awt.Color is a pain due to all the javacasts ...
        function createAwtColor(r, g, b, alpha) {
            var color = createObject("java", "java.awt.Color");
            return color.init( javacast("int", arguments.r)
                                , javacast("int", arguments.g)
                                , javacast("int", arguments.b)
                                , javacast("int", arguments.alpha) // transparency
                            );  
        }
</cfscript>     

//我的图表设置
chartTitle=“我的拨号表”;
箭头值=55;
最小值=0;
最大值=100;
图表宽度=500;
图表高度=500;
//初始化图表的基本组件
//有关如何进一步自定义组件设置,请参见jFreeChart API
DefaultValueDataset=createObject(“java”、“org.jfree.data.general.DefaultValueDataset”);
pointerValue=DefaultValueDataset.init(箭头值);
dialPointer=createObject(“java”、“org.jfree.chart.plot.dial.dialPointer$Pointer”).init();
dialFrame=createObject(“java”,“org.jfree.chart.plot.dial.StandardDialFrame”).init();
dialBackground=createObject(“java”,“org.jfree.chart.plot.dial.dialBackground”).init();
//调整默认范围以使其更具吸引力。
//请参见角度/范围:http://java.sun.com/developer/technicalArticles/GUI/java2d/java2dpart1.html
dialScale=createObject(“java”,“org.jfree.chart.plot.dial.StandardDialScale”).init();
dialScale.setLowerBound(拨号最小值);
dialScale.setUpperBound(拨号最大值);
刻度盘。设置起始角(-150);
dialScale.setExtent(-240);
//初始化打印并应用设置
plot=createObject(“java”,“org.jfree.chart.plot.dial.DialPlot”).init();
plot.setDialFrame(dialFrame);
情节。挫折背景(背景);
plot.setDataset(pointerValue);
plot.addScale(0,dialScale);
plot.addPointer(拨号指针);
//创建图表并将其转换为图像
chart=createObject(“java”,“org.jfree.chart.JFreeChart”).init(图表标题,绘图);
chartImage=chart.createBuffereImage(图表宽度、图表高度);
ImageFormat=createObject(“java”、“org.jfree.chart.encoders.ImageFormat”);
EncoderUtil=createObject(“java”,“org.jfree.chart.encoders.EncoderUtil”);
字节=EncoderUtil.encode(chartImage,ImageFormat.PNG);
(这可能不应该是一个单独的答案,但另一个答案已经很长了。因此,我将分别发布它,以使内容井然有序,易于查找。)

如果您正在寻找jFreeChart所称的MeterChart,下面是该图表类型的一个快速而肮脏的示例

仪表零件代码:

<cfscript>
// my chart settings
chartTitle = "My Dial Chart";
arrowValue  = 55;
dialMinimum = 0;
dialMaximum = 100;
chartWidth  = 500;
chartHeight = 500;

// initialize basic components of the chart
// see jFreeChart API on how to customize the components settings further 
DefaultValueDataset = createObject("java", "org.jfree.data.general.DefaultValueDataset");
pointerValue    = DefaultValueDataset.init(arrowValue);
dialPointer     = createObject("java", "org.jfree.chart.plot.dial.DialPointer$Pointer").init();
dialFrame       = createObject("java", "org.jfree.chart.plot.dial.StandardDialFrame").init();
dialBackground  = createObject("java", "org.jfree.chart.plot.dial.DialBackground").init();
// tweak the default range to make it more appealing.
// see angle/extent: http://java.sun.com/developer/technicalArticles/GUI/java2d/java2dpart1.html
dialScale = createObject("java", "org.jfree.chart.plot.dial.StandardDialScale").init();
dialScale.setLowerBound(dialMinimum);
dialScale.setUpperBound(dialMaximum);
dialScale.setStartAngle(-150);
dialScale.setExtent(-240);

//initialize plot and apply settings
plot = createObject("java", "org.jfree.chart.plot.dial.DialPlot").init();
plot.setDialFrame(dialFrame);
plot.setBackground(dialBackground);
plot.setDataset(pointerValue);
plot.addScale(0, dialScale);
plot.addPointer(dialPointer);

// create chart and convert it to an image
chart = createObject("java", "org.jfree.chart.JFreeChart").init(chartTitle, plot);
chartImage = chart.createBufferedImage(chartWidth, chartHeight);
ImageFormat = createObject("java", "org.jfree.chart.encoders.ImageFormat");
EncoderUtil = createObject("java", "org.jfree.chart.encoders.EncoderUtil");
bytes = EncoderUtil.encode( chartImage, ImageFormat.PNG);
</cfscript>

<!--- display in browser --->
<cfcontent type="image/png" variable="#bytes#">
<cfscript>
    // my chart settings
    chartTitle = "My Meter Chart";
    arrowValue  = 55;
    arrowUnits  = "widgets";
    chartWidth  = 500;
    chartHeight = 500;

    // initialize meter ranges (LOW, MEDIUM, HIGH)
    // note: quick and ugly code in dire need of improvement ...
    low  = createSolidMeterInterval("Low", 0, 40, createAwtColor(0, 255, 0, 120));
    med  = createSolidMeterInterval("Med", 40, 60, createAwtColor(255, 255, 0, 120));
    high = createSolidMeterInterval("High", 60, 100, createAwtColor(255, 0, 0, 120));

    // initialize arrow value
    DefaultValueDataset = createObject("java", "org.jfree.data.general.DefaultValueDataset");
    meterPointer = DefaultValueDataset.init(arrowValue);

    //initialize plot and apply settings
    plot = createObject("java", "org.jfree.chart.plot.MeterPlot").init();
    plot.setDataset(meterPointer);
    plot.setTickLabelsVisible(true);
    plot.addInterval(low);
    plot.addInterval(med);
    plot.addInterval(high);
    plot.setUnits(arrowUnits);

    // create chart and convert it to an image
    chart = createObject("java", "org.jfree.chart.JFreeChart").init(chartTitle, plot);
    ChartUtilities = createObject("java", "org.jfree.chart.ChartUtilities");
    ChartUtilities.applyCurrentTheme(chart);

    // applyCurrentTheme seems to overwrite some settings, so we must reapply them 
    Color = createObject("java", "java.awt.Color");
    plot.setBackgroundPaint(Color.GRAY);
    plot.setNeedlePaint(Color.BLACK);

    chartImage = chart.createBufferedImage(chartWidth, chartHeight);
    ImageFormat = createObject("java", "org.jfree.chart.encoders.ImageFormat");
    EncoderUtil = createObject("java", "org.jfree.chart.encoders.EncoderUtil");
    bytes = EncoderUtil.encode( chartImage, ImageFormat.PNG); 
</cfscript>
<!--- display in browser --->
<cfcontent type="image/png" variable="#bytes#">
<cfscript>
        // quick and ugly functions. could be improved ...  
        function createSolidMeterInterval(Title, fromValue, toValue, BgColor) {
            var Range = createObject("java", "org.jfree.data.Range").init(arguments.fromValue, arguments.toValue);
            var MeterInterval = createObject("java", "org.jfree.chart.plot.MeterInterval");
            return MeterInterval.init(arguments.Title, Range   // interval from / to range 
                                        , javacast("null", "") // outline color
                                        , javacast("null", "") // outline stroke
                                        , arguments.BgColor    // background color
                                    );
        }


        // using java.awt.Color is a pain due to all the javacasts ...
        function createAwtColor(r, g, b, alpha) {
            var color = createObject("java", "java.awt.Color");
            return color.init( javacast("int", arguments.r)
                                , javacast("int", arguments.g)
                                , javacast("int", arguments.b)
                                , javacast("int", arguments.alpha) // transparency
                            );  
        }
</cfscript>     

//我的图表设置
chartTitle=“我的仪表图表”;
箭头值=55;
箭头单位=“wi