FusionCharts API-Event: printCancelled

Created using FusionCharts Suite XT - www.fusioncharts.com

by FusionCharts

HTML

<script src="https://static.fusioncharts.com/code/latest/fusioncharts.js"></script>
<script src="https://static.fusioncharts.com/code/latest/fusioncharts.widgets.js"></script>
<!-- This sample shows the event parameters, and their values, when printCancelled event is triggered-->
<div id="indicatorDiv">Event name: <strong> printCancelled </strong> 
    
    <p>Triggered when the default behavior of the beforePrint event is cancelled by calling the eventObj.preventDefault() method.</p>
    <p>When triggered, the beforePrint event provides the <strong> eventObj </strong> object (object containing information generic to all events) parameter to the event handler.</p>
    <p>Scroll down to the table rendered below the chart to view information contained in the eventObj object.</p>
    
</div>
<div id="chart-container">FusionCharts will render here</div>
<button id="print">Print</button>
<div>
    <div>
        <div id="header">
            <div class="parameter-name">Parameter Name</div>
            <div class="parameter-value">Parameter Value</div>
        </div>
        <div id="attrs-table"></div>
    </div>
</div>

CSS

body {
    padding: 5px;
    margin: 0 auto;
}
strong{
  font-weight: bold;
}
#header {
    display: none;
}
#indicatorDiv {
    width: 500px;
    font-family:'Arial', 'Helvetica';
    font-size: 14px;
}
p {
    margin-top: 20px;
    margin-bottom: 20px;
}
#attrs-table {
    text-align: center;
    width: 500px;
}
.parameter-name, .parameter-value {
    width: 250px;
    font-weight: bold;
    text-align: center;
    float: left;
}
.title, .value {
    float:left;
    width: 230px;
    height: 20px;
    background: #fff;
    padding: 5px 10px;
}
.title {
    clear: left;
}
.title:nth-child(4n+1), .value:nth-child(4n+2) {
    background: rgb(0, 117, 194);
    color: #fff;
}
.value {
    word-wrap: break-word;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}
#print {
  padding: 10px;
  margin-top: 10px;
}

JavaScript

FusionCharts.ready(function () {
    var salesChart = new FusionCharts({
        type: 'vled',
        renderAt: 'chart-container',
        id: 'myChart',
        width: '200',
        height: '300',
        dataFormat: 'json',
        dataSource: {
            "chart": {
                "caption": "Current Flow on Main Meter",
                    "subcaption": "New York Store",
                    "chartleftmargin": "40",
                    "chartbottommargin": "20",
                    "gaugebgcolor": "#ff0000",
                    "gaugefillcolor": "#1f0601",
                    "lowerlimit": "100",
                    "upperlimit": "400",
                    "numbersuffix": " amp",
                    "bgalpha": "0",
                    "borderalpha": "20",
                    "showborder": "1",
                    "minortmalpha": "0",
                    "animation": "1",
                    "showvalue": "1",
                    "valuespadding": "10",
                    "valuefontbold": "1",
                    "ledgap": "0"
            },
                "colorrange": {
                "color": [{
                    "minvalue": "100",
                        "maxvalue": "400",
                        "code": "#ff0000"
                }]
            },
                "value": "250"
        },
            "events": {
            "rendered": function (evt, data) {
                var btn = document.getElementById('print');
                btn.addEventListener('click', function () {
                    evt.sender.print();
                });
            },
                // Cancelling the print action. This will trigger the printCancelled event
                "beforePrint": function (eventObj) {
                    eventObj.preventDefault();
                },     

                /**
                 * @description
                 *Triggered when the default behavior of the beforePrint event is cancelled by calling the eventObj.preventDefault() method....