离开系列时销毁kendo ui图表工具提示

时间:2020-09-09 14:47:00

标签: javascript jquery kendo-ui

我想在离开系列时销毁kendo ui图表的工具提示,因为kendo具有默认的始终激活的工具提示功能,该功能显示我不希望的系列以前的值,因此我想通过两种方式销毁工具提示。 1>一次删除就离开图表柱系列,或者2>仅在我将鼠标悬停在柱系列上时显示工具提示

我尝试下面的代码,但是不起作用

if (response.CampaignUploadSummaryItems[i].HasCampaignCostDataUploadSummary) {
                    var chartDataOptions = {
                        dataSource: { data: response.CampaignUploadSummaryItems[i].CampaignCostDataUploadSummary },
                        categoryAxis: [{
                            field: 'Station',
                            majorGridLines: { visible: false },
                            line: { visible: true },
                            minorGridLines: { visible: false },
                            labels: { rotation: 'auto' }
                        }],
                        series: [{ field: 'OldGrossBudget', name: 'Old Gross Budget', axis: 'left' },
                            { field: 'NewGrossBudget', name: 'New Gross Budget', axis: 'left' }],
                        valueAxis: { name: 'left', title: { text: 'Gross Budget' }, labels: { format: '{0:#,#.##}' } },
                        legend: { item: { visual: chartLegend } },
                        tooltip: { visible: false },
                        seriesHover: function (e) {
                            var htmlData = getToolTipTemplate(e);
                            var tdClass = e.series.name.replace(/[^A-Za-z0-9]+/g, '');
                            onSeriesHover(tdClass, htmlData, e.sender.element.attr('id'));
                        }
                    };
                    $.extend(true, chartOptions, chartDataOptions);
                    $('#costChart' + response.CampaignUploadSummaryItems[i].CampaignID).kendoChart(chartOptions);
                }
                if (response.CampaignUploadSummaryItems[i].HasCampaignSpotDataUploadSummary) {
                    var chartDataOptions = {
                        dataSource: { data: response.CampaignUploadSummaryItems[i].CampaignSpotDataUploadSummary },
                        series: [{ field: 'OldImpacts', name: 'Old Impacts', type: 'column', axis: 'left' },
                                    { field: 'NewImpacts', name: 'New Impacts', type: 'column', axis: 'left' },
                                    { field: 'OldSpotCounts', name: 'Old Spot Counts', type: 'line', axis: 'right' },
                                    { field: 'NewSpotCounts', name: 'New Spot Counts', type: 'line', axis: 'right' }
                        ],
                        valueAxis: [{ name: 'left', title: { text: 'Impacts' }, labels: { format: '{0:#,#.##}' } },
                                    { name: 'right', title: { text: 'Spot Count' }, labels: { format: '{0:#,#}' } }],
                        legend: { item: { visual: chartLegend } },
                        categoryAxis: {
                            axisCrossingValue: [0, 10000],
                            field: 'DateString',
                            majorGridLines: { visible: false },
                            line: { visible: true },
                            minorGridLines: { visible: false },
                            labels: { rotation: 'auto' }
                        },
                        tooltip: { visible: false },
                        seriesHover: function (e) {
                            var htmlData = getToolTipTemplate(e);
                            var tdClass = e.series.name.replace(/[^A-Za-z0-9]+/g, '');
                            onSeriesHover(tdClass, htmlData, e.sender.element.attr('id'));
                        }
                    }
                    $.extend(true, chartOptions, chartDataOptions);
                    $('#spotChart' + response.CampaignUploadSummaryItems[i].CampaignID).kendoChart(chartOptions);
                }
            }

尝试下面的代码,但什么也没发生

seriesLeave: function(e){
  this.hideTooltip();
},
seriesOver: function(e){
  var category = e.category;
  var value = e.value;
  this.showTooltip(function(point) {
    return point.value == value && point.category == category;
  });
}

0 个答案:

没有答案
相关问题