Criccle / GoogleCombo

Apache License 2.0
0 stars 0 forks source link

Options for Google Chart are very limited. #2

Open isamu-tanaka opened 7 years ago

isamu-tanaka commented 7 years ago

The current implementation for this module allows very limited options of Google Chart. No more than two charts can be configured.
It is better to import JSON for the options.

Criccle commented 7 years ago

Hi Isamu! Thanks for your input, I agree with you on the JSON part. Unfortunately I haven't been able to get this working properly yet. Do you have any ideas on how to achieve this? If so, feel free to contribute, or make suggestions. I would appreciate the input and I'm sure together it's fixable.

isamu-tanaka commented 7 years ago

My idea is:

define([

"dojo/_base/declare", "dojo/_base/lang", "dojo/query", "dojo/on", "ChartJS/widgets/Core"

], function (declare, lang, domQuery, on, _core) { "use strict";

var chartjssetting = JSON.parse(this.chartjssetting); var sourcejsonstring = JSON.parse(this.sourcejsonstring);

// Declare widget.
return declare("ChartJS.widgets.ExpertChart.widget.ExpertChart", [ _core ], {

    // Overwrite functions from _core here...

    _processData : function () {
        logger.debug(this.id + "._processData");
        var sets = [];
        this._chartData = chartjssetting;
        sets = this._data.datasets = this._sortArrayObj(chartjssetting.datasets);
        this._createChart(sourcejsonstring);
        this._createLegend(false);
    },

    _createChart : function (data) {
        logger.debug(this.id + "._createChart");

        if (this._chart) {
            this._chart.stop();
            this._chart.data = data;
            this._chart.update(1000);
            this._chart.bindEvents(); // tooltips otherwise won't work
        } else {

            chartjssetting.data = data;
            this._chart = new this._chartJS(this._ctx, chartjssetting);
        }

        this.connect(window, "resize", lang.hitch(this, function () {
            this._resize();
        }));

        // Add class to determain chart type
        this._addChartClass("chartjs-expert-bar-chart");

        if (this.onclickmf) {
            on(this._chart.chart.canvas, "click", lang.hitch(this, this._onClickChart));
        }
    }
});

}); require(["ChartJS/widgets/ExpertChart/widget/ExpertChart"], function () { "use strict"; });

Simply, pass all the chatjs setting as JSON string to the widget. Thanks!

Criccle commented 7 years ago

Thanks for the input Isamu! I will put it on my todo list and try to make some time next week!