--- /dev/null
+/*
+Copyright (c) Igor Barma, Alexandre Desoubeaux, Christian Martel, Eric Brun, Mathieu Amblard, Gwenael Gevet, Pierre Guillot, 2012
+ * Copyright Alexandre Desoubeaux, Christian Martel, Cedric Lecarpentier, Alexandre Lefevre, Marc Salvat 2014-2016
+ * Copyright Alexandre Desoubeaux, Christian Martel, Cedric Lecarpentier, Marc Salvat, Marc Suarez, Harifetra Ramamonjy 2017
+For licensing, see README.txt or http://www.pentilanero.com (Cecill-C or AGPL or LGPL)
+*/
+Ext.ns("EntSavoie");
+EntSavoie.Chart = function (config) {
+ Ext.apply(this, config);
+
+ // Ajoute le texte des erreurs
+ Ext.QuickTips.init();
+
+ // turn on validation errors beside the field globally
+ Ext.form.Field.prototype.msgTarget = 'side';
+
+ YAHOO.widget.Chart.SWFURL = "/html/js/extjs/chart/swf/charts.swf";
+
+ this.fields = this.fields || ["name", "value"];
+ this.data = this.data || [];
+
+ this.type = this.type || "column";
+
+ this.chartConfig = this.chartConfig || {
+ xField: this.xField || "name",
+ yField: this.yField || "value"
+ };
+
+ EntSavoie.Chart.superclass.constructor.call(this, {});
+
+ this.on("render", this.onRenderChartPanel, this);
+};
+
+Ext.extend(EntSavoie.Chart, Ext.Panel, {
+ initComponent: function () {
+ EntSavoie.Chart.superclass.initComponent.call(this);
+ },
+
+ onRenderChartPanel: function(panel){
+ this.refresh(this.data);
+ },
+
+ refresh: function(data){
+ this.data = data;
+ this.myDataSource = new YAHOO.util.DataSource(this.data);
+ this.myDataSource.responseType = YAHOO.util.DataSource.TYPE_JSARRAY;
+ this.myDataSource.responseSchema = {
+ fields: this.fields
+ };
+
+ switch (this.type) {
+ case "column":
+ this.myChart = new YAHOO.widget.ColumnChart(this.id, this.myDataSource, this.chartConfig);
+ break;
+ case "line":
+ this.myChart = new YAHOO.widget.LineChart(this.id, this.myDataSource, this.chartConfig);
+ break;
+ case "pie":
+ this.myChart = new YAHOO.widget.PieChart(this.id, this.myDataSource, this.chartConfig);
+ break;
+ case "bar":
+ this.myChart = new YAHOO.widget.BarChart(this.id, this.myDataSource, this.chartConfig);
+ break;
+ default:
+ this.myChart = new YAHOO.widget.ColumnChart(this.id, this.myDataSource, this.chartConfig);
+ break;
+ }
+
+ },
+
+ setConfig: function(config){
+ Ext.apply(this, config);
+ this.refresh(this.data);
+ }
+
+});