Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Remote Application Platform (RAP) » Custom widget for fusioncharts
Custom widget for fusioncharts [message #1426338] Thu, 18 September 2014 15:45 Go to next message
Alexandru LATAFriend
Messages: 8
Registered: October 2013
Junior Member
Hi all,

Does anyone managed to create a custom widget for fusioncharts?
Any hints/ideas/code snippet would help me a lot. Thanks in advance!

Regards,
Alex
Re: Custom widget for fusioncharts [message #1441838 is a reply to message #1426338] Fri, 10 October 2014 08:56 Go to previous message
Alexandru LATAFriend
Messages: 8
Registered: October 2013
Junior Member
Hi all,

Well in the end it wasn't very hard to do this (for someone who never touched js).
Here's the code of the handler.js :
(function() {
	'use strict';

	// Chart constructor.
	var Chart = function(properties) {
		var el = document.createElement("divChart");
		el.style.position = "absolute";
		el.style.left = "0px";
		el.style.top = "0px";
		el.style.width = "100%";
		el.style.height = "100%";

		this._el = el;
		this._hasModifyListener = false;

		// Create the chart.
		var chartId = properties.chartId;
		var chartType = properties.chartType;
		var chartWidth = properties.chartWidth;
		var chartHeight = properties.chartHeight;

		var myChart = new FusionCharts(chartType, chartId, chartWidth, chartHeight, "0", "1");

		// Set chart data.
		var chartData = properties.chartData;
		myChart.setJSONData(chartData);

		// Render the chart.
		myChart.render(this._el);
	};

	Chart.prototype = {

		getElement : function() {
			return this._el;
		}

	};

	rap.registerTypeHandler("fusionchart.Chart", {

		factory : function(properties) {
			var result = new Chart(properties);
			rap.getObject(properties.parent).append(result.getElement());
			return result;
		},

		destructor : function(widget) {
			var el = widget.getElement();
			if (el.parentNode) {
				el.parentNode.removeChild(el);
			}
		}

	});

}());


The Chart class is pretty straightforward, consider checking the CKEditor example.

Best regards,
Previous Topic:Dialog.open() method packs all my Views
Next Topic:RAP 3.0 + BIRT 4.4 Tomcat WAR deployment
Goto Forum:
  


Current Time: Mon Feb 17 00:58:33 GMT 2020

Powered by FUDForum. Page generated in 0.03651 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top