如何在jsp中单击按钮时将代码添加到jqPlot条形图另存为图像

How to add codes to jqPlot bar chart save as image on button click in jsp

本文关键字:添加 代码 jqPlot 条形图 图像 另存为 jsp 按钮 单击      更新时间:2023-09-26

我在jsp中显示了一个jqPplot条形图。现在我已经看到了一个按钮单击选项,可以将图表作为图像查看并将其保存到图像中,但我不知道如何实现这一点..我添加了按钮代码。

这是我的代码。

 <script type="text/javascript">
        $(document).ready(function(){
            $.jqplot.config.enablePlugins = true;
            var s1 = [200, 600, 700, 1000,1400];
            var ticks = ['Local', 'STD', 'ISD', 'INET','Incoming'];
            plot1 = $.jqplot('chart1', [s1], {
                // Only animate if we're not using excanvas (not in IE 7 or IE 8)..
                animate: !$.jqplot.use_excanvas,
                seriesDefaults:{
                    renderer:$.jqplot.BarRenderer,
                    pointLabels: { show: true }
                },
                axes: {
                    xaxis: {
                        renderer: $.jqplot.CategoryAxisRenderer,
                        ticks: ticks
                    }
                },
                highlighter: { show: true }
            });
            $('#chart1').bind('jqplotDataClick',
            function (ev, seriesIndex, pointIndex, data) {
                $('#info1').html('series: '+seriesIndex+', point: '+pointIndex+', data: '+data);
            }
        );
        });
    </script>
</head>
<body>
    <br/>
    <br/>
    <input type="submit" name="ViewImage" id="view" value="ViewImage">
    <div name="chart1" id="chart1" value="chart1" style="height: 300px;width: 400px;left: 100px">
</body>

任何帮助将不胜感激。

提前谢谢..

不使用输入,使用按钮

和功能是:

$("#div_ID').jqplotSaveImage();