Once you are done with the inclusion of library files, keep the code that will define a custom element class which extends the Polymer.Element. This is where the chart will be defined using the code mentioned below: Once you are done with the inclusion of library files, keep the code that will define a custom element class which extends the Polymer.Element. This is where the chart will be defined using the code mentioned below:
<script>
// Your new element extends the Polymer.Element base class
class ChartElement extends Polymer.Element {
static get is() { return 'polymer-fusioncharts'; }
constructor() {
super();
this.textContent = "Rendering the chart using the Polymer custom element(containing the chart)";
this.style = "align: center";
var iDiv = document.createElement('div');
iDiv.id = 'chart-container';
document.getElementsByTagName('body')[0].appendChild(iDiv);
FusionCharts.ready(function () {
var conversionChart = new FusionCharts({
type: 'bubble',
renderAt: 'chart-container',
width: '100%',
height: '550',
dataFormat: 'json',
dataSource: {
"chart": {
"theme": "fint",
"caption": "Popular Text Editors - 2016",
"captionFontSize": "20",
"captionPadding": "20",
"xAxisMinValue": "0",
"xAxisMaxValue": "100",
"yAxisMinValue": "0",
"yAxisMaxValue": "10",
"xAxisName": "Customer Satisfaction",
"yAxisName": "Market Presence Rating{br}(Out of 10)",
"xAxisNameFontSize": "12",
"yAxisNameFontSize": "12",
"numDivlines": "9",
"bubbleScale": "1",
"showValues": "1",
"divLineColor": "#72D7B2",
"plotFillHoverColor": "#98e6e6",
"plotTooltext": "$name{br}Overall Rating - $zvalue",
//Drawing quadrants on chart
"drawQuadrant" : "1",
"quadrantLineAlpha" : "50",
"quadrantLineThickness" : "1"
},
"categories": [
{
"category": [
{
"label": "0",
"x": "0"
},
{
"label": "25 %",
"x": "25",
"showverticalline": "1"
},
{
"label": "50 %",
"x": "50",
"showverticalline": "1"
},
{
"label": "75 %",
"x": "75",
"showverticalline": "1"
},
{
"label": "100 %",
"x": "100",
"showverticalline": "1"
}
]
}
],
"dataset": [
{
"color":"#00aee4",
"data": [
{
"x": "78",
"y": "7.4",
"z": "8",
"name": "Dreamweaver",
"color": "#d35f61"
},
{
"x": "92",
"y": "5.1",
"z": "9.2",
"name": "Sublime Text",
"color": "#86bb5d"
},
{
"x": "60",
"y": "5",
"z": "6",
"name": "Brackets",
"color": "#ffbb99"
},
{
"x": "59",
"y": "3.1",
"z": "5",
"name": "TextPad",
"color": "#ce99ff"
},
{
"x": "9",
"y": "1.8",
"z": "3",
"name": "Elvis",
"color": "#7d9bcf"
},
{
"x": "83",
"y": "4",
"z": "7.4",
"name": "Atom",
"color": "#e19951"
},
{
"x": "93",
"y": "3.6",
"z": "8.3",
"name": "Notepad++",
"color": "#8a8f8f"
},
{
"x": "29",
"y": "3.8",
"z": "5",
"name": "G Edit",
"color": "#d4cb11"
},
{
"x": "45",
"y": "2.5",
"z": "8",
"name": "Edit+",
"color": "#c8c8c8"
},
{
"x": "47",
"y": "3.8",
"z": "4",
"name": "VIM Edit",
"color": "#b27666"
}
]
}
],
"vTrendLines": [
{
"line": [
{
"startValue": "50",
"endValue": "75",
"isTrendZone": "1",
"color": "#aaaaaa",
"alpha": "14"
},
{
"startValue": "75",
"endValue": "100",
"isTrendZone": "1",
"color": "#aaaaaa",
"alpha": "21"
},
{
"startValue": "25",
"endValue": "50",
"isTrendZone": "1",
"color": "#aaaaaa",
"alpha": "7"
}
]
}
]
}
}).render();
});
}
}
//Now, register your new custom element so the browser can use it
customElements.define(ChartElement.is, ChartElement);
</script>