Example #1
0
 this._redrawChartTimeout = setTimeout(function() {
     if(self.chart.requiresExternalColorPalette()) {
         self.setChartColorPalette();
     }
     var startTime = new Date().getTime();
     self.chart.draw();
     if (console.DEBUG_ENABLED) {
         console.log('Chart=%o drawn in duration=%o ms',
                 self.model.get('display.visualizations.charting.chart'), new Date().getTime() - startTime);
     }
     self.trigger('rendered', self);
 }, 5);
Example #2
0
 _onDataChanged: function() {
     if (!this.resultsModel.hasData()) {
         if (this._isJobDone) {
             this.message('no-results');
         }
         return;
     }
     
     var chartData = this.resultsModel.data();
     console.log('chart data changed:', chartData);
     
     if (chartData.fields.length) {
         this.chartData = chartData;
         this.updateChart();
     }
 },
Example #3
0
        updateChart: function() {
            if(this._err) { return; }
            console.log('updateChart data=%o this.chart=%o', this.chartData, this.chart);
            if (this.chartData) {
                if(this.chart) {
                    this.$msg.detach();
                    this.$inlineMsg.empty();
                    var processedChartData = jschartingUtils.preprocessChartData(this.chartData, this.chart.getCurrentDisplayProperties()),
                        chartReadyData = JSCharting.extractChartReadyData(processedChartData);

                    this.chart.prepare(
                        chartReadyData,
                        jschartingUtils.getCustomDisplayProperties(chartReadyData, splunkConfig)
                    );
                    // if the preprocessChartData method truncated the data, show a message to that effect
                    if(processedChartData.columns.length > 0 &&
                            (processedChartData.columns.length < this.chartData.columns.length ||
                                processedChartData.columns[0].length < this.chartData.columns[0].length)) {
                        this.inlineMessage({
                            level: 'warn',
                            message: _('These results may be truncated. Your search generated too much data for the current visualization configuration.').t()
                        });
                    }
                    // otherwise if the number of results matches the max result count that was used to fetch,
                    // show a message that we might not be displaying the full data set
                    else if(this.chartData.columns.length > 0 && this.maxResultCount > 0 &&
                            this.chartData.columns[0].length >= this.maxResultCount) {
                        this.inlineMessage({
                            level: 'warn',
                            message: SplunkUtil.sprintf(
                                _('These results may be truncated. This visualization is configured to display a maximum of %s results per series, and that limit has been reached.').t(),
                                this.maxResultCount
                            )
                        });
                    }
                    this.updateChartContainerHeight();
                    if(this.chart.requiresExternalColorPalette()) {
                        var fieldList = this.chart.getFieldList();
                        SplunkLegend.setLabels(this.cid, fieldList);
                    }
                    this.invalidateChart();
                } else {
                    this.createChart();
                }
                this.trigger('rendered', this);
            }
        },
Example #4
0
        _createChart: function() {
            // Initialize the chart with the type if it is there. If somebody
            // actually specified charting.chart, that option will win.
            var displayProperties = {'chart': this.settings.get("type")};

            // Copy over the settings for everything that starts with the 
            // prefix (charting.) by default.
            var prefix = this.chartOptionPrefix;
            _.each(this.settings.toJSON(), function(value, key){
                if(key.substring(0, prefix.length) == prefix) {
                    displayProperties[key.substring(prefix.length)] = value;
                }
            }, this);

            if(this._err) { return; }

            this.$msg.detach();
            console.log('Creating chart with data: ', displayProperties);
            var chart = this.chart = JSCharting.createChart(this.$chart, displayProperties);
            chart.on('pointClick', this.emitDrilldownEvent.bind(this));
            chart.on('legendClick', this.emitDrilldownEvent.bind(this));
            this.updateChart();
        },