图表JS对象弃用chartDataSetsNonNull、nameNonNull、updateIntervalNonNull函数

This commit is contained in:
datagear 2021-04-13 13:00:14 +08:00
parent 28dc422d6a
commit 8a4f2ef4db
5 changed files with 89 additions and 73 deletions

View File

@ -417,6 +417,7 @@ DataGear版本更新日志
改进看板JS对象loadChart函数支持不设置chartWidgetId参数而默认从元素的dg-chart-widget属性读取
改进看板JS对象异步加载图表在未找到对应图表时返回备用的图表对象
改进看板JS对象refreshData、removeChart等函数的chartInfo参数支持传入Jquery对象和HTML元素
改进图表JS对象弃用chartDataSetsNonNull、nameNonNull、updateIntervalNonNull函数
改进:看板内置地图添加默认编码映射;
改进:数据集编辑页面支持调整参数和属性顺序,支持为属性设置默认值;
改进:数据集保存操作在有重名参数或属性时给出友好错误提示;

View File

@ -378,10 +378,23 @@
*/
chartBase.init = function()
{
if(!this.id)
throw new Error("[this.id] must be defined");
if(!this.elementId)
throw new Error("[this.elementId] must be defined");
if(!this.renderContext)
throw new Error("[this.renderContext] must be defined");
if(!this.plugin)
throw new Error("[this.plugin] must be defined");
if(this._inited == true)
throw new Error("Chart has been initialized");
this._inited = true;
this.name = (this.name || "");
this.chartDataSets = (this.chartDataSets || []);
this.updateInterval = (this.updateInterval == null ? -1 : this.updateInterval);
this._initBaseProperties();
this._initOptions();
this._initTheme();
@ -1358,7 +1371,7 @@
{
var re = false;
var chartDataSets = this.chartDataSetsNonNull();
var chartDataSets = this.chartDataSets;
for(var i=0; i<chartDataSets.length; i++)
{
var params = chartDataSets[i].dataSet.params;
@ -1380,7 +1393,7 @@
{
chartDataSet = (typeof(chartDataSet) == "number" ? this.chartDataSets[chartDataSet] : chartDataSet);
var chartDataSets = (chartDataSet ? [ chartDataSet ] : this.chartDataSetsNonNull());
var chartDataSets = (chartDataSet ? [ chartDataSet ] : this.chartDataSets);
for(var i=0; i<chartDataSets.length; i++)
{
@ -1499,25 +1512,6 @@
return chartFactory.elementWidgetId(this.element());
};
/**
* 获取图表名称
*/
chartBase.nameNonNull = function()
{
return (this.name || "");
};
/**
* 获取图表的更新间隔
*/
chartBase.updateIntervalNonNull = function()
{
if(this.updateInterval != null)
return this.updateInterval;
return -1;
},
/**
* 获取图表对应的图表部件ID
* 正常来说此函数的返回值与期望渲染的图表部件ID相同通常是chartBase.elementWidgetId()的返回值
@ -1568,14 +1562,6 @@
}
};
/**
* 获取所有图表数据集对象数组
*/
chartBase.chartDataSetsNonNull = function()
{
return (this.chartDataSets || []);
};
/**
* 获取主件图表数据集对象数组它们的用途是绘制图表
*
@ -1585,7 +1571,7 @@
{
var re = [];
var chartDataSets = this.chartDataSetsNonNull();
var chartDataSets = this.chartDataSets;
for(var i=0; i<chartDataSets.length; i++)
{
if(chartDataSets[i].attachment)
@ -1606,7 +1592,7 @@
{
var re = [];
var chartDataSets = this.chartDataSetsNonNull();
var chartDataSets = this.chartDataSets;
for(var i=0; i<chartDataSets.length; i++)
{
if(chartDataSets[i].attachment)
@ -1640,7 +1626,7 @@
var re = undefined;
var chartDataSets = this.chartDataSetsNonNull();
var chartDataSets = this.chartDataSets;
for(var i=0; i<chartDataSets.length; i++)
{
var isAttachment = chartDataSets[i].attachment;
@ -1783,7 +1769,7 @@
var index = undefined;
var chartDataSets = this.chartDataSetsNonNull();
var chartDataSets = this.chartDataSets;
for(var i=0; i<chartDataSets.length; i++)
{
var isAttachment = chartDataSets[i].attachment;
@ -2381,6 +2367,39 @@
// < 已弃用函数 start
//-------------
// < @deprecated 兼容2.3.0版本的API将在未来版本移除已被chartBase.chartDataSets取代
/**
* 获取所有图表数据集对象数组
*/
chartBase.chartDataSetsNonNull = function()
{
return (this.chartDataSets || []);
};
// > @deprecated 兼容2.3.0版本的API将在未来版本移除已被chartBase.chartDataSets取代
// < @deprecated 兼容2.3.0版本的API将在未来版本移除已被chartBase.name取代
/**
* 获取图表名称
*/
chartBase.nameNonNull = function()
{
return (this.name || "");
};
// > @deprecated 兼容2.3.0版本的API将在未来版本移除已被chartBase.name取代
// < @deprecated 兼容2.3.0版本的API将在未来版本移除已被chartBase.updateInterval取代
/**
* 获取图表的更新间隔
*/
chartBase.updateIntervalNonNull = function()
{
if(this.updateInterval != null)
return this.updateInterval;
return -1;
},
// > @deprecated 兼容2.3.0版本的API将在未来版本移除已被chartBase.updateInterval取代
// < @deprecated 兼容1.8.1版本的API将在未来版本移除已被chartBase.dataSetParamValues取代
/**
* 获取指定图表数据集参数值对象

View File

@ -1306,7 +1306,7 @@
{
var $chart = chart.elementJquery();
var chartDataSets = chart.chartDataSetsNonNull();
var chartDataSets = chart.chartDataSets;
var $panel = $(".dg-chart-setting-param-panel", $box);
@ -1438,7 +1438,7 @@
{
var $chart = chart.elementJquery();
var chartDataSets = chart.chartDataSetsNonNull();
var chartDataSets = chart.chartDataSets;
var $panel = $(".dg-chart-setting-data-panel", $box);

View File

@ -40,7 +40,7 @@
options = $.extend(true,
{
title: {
text: chart.nameNonNull()
text: chart.name
},
tooltip:
{
@ -196,7 +196,7 @@
options = $.extend(true,
{
title: {
text: chart.nameNonNull()
text: chart.name
},
tooltip:
{
@ -362,7 +362,7 @@
dgStack: stack,
dgAxisType: axisType,
title: { text: chart.nameNonNull() },
title: { text: chart.name },
angleAxis: {},
radiusAxis: {},
polar: { radius: "60%" },
@ -518,7 +518,7 @@
options = $.extend(true,
{
title: {
text: chart.nameNonNull()
text: chart.name
},
tooltip:
{
@ -532,7 +532,7 @@
series:
[
{
name: chart.nameNonNull(),
name: chart.name,
type: "pie",
radius: "55%",
center: ["50%", "60%"],
@ -632,7 +632,7 @@
options = $.extend(true,
{
title: {
text: chart.nameNonNull()
text: chart.name
},
tooltip:
{
@ -733,7 +733,7 @@
options = $.extend(true,
{
title: {
text: chart.nameNonNull()
text: chart.name
},
tooltip:
{
@ -893,7 +893,7 @@
options = $.extend(true,
{
title: {
text: chart.nameNonNull()
text: chart.name
},
tooltip:
{
@ -1040,7 +1040,7 @@
options = $.extend(true,
{
title: {
text: chart.nameNonNull()
text: chart.name
},
tooltip:
{
@ -1247,7 +1247,7 @@
options = $.extend(true,
{
title: {
text: chart.nameNonNull()
text: chart.name
},
tooltip:
{
@ -1497,7 +1497,7 @@
options = $.extend(true,
{
title: {
text: chart.nameNonNull()
text: chart.name
},
tooltip:
{
@ -1643,7 +1643,7 @@
options = $.extend(true,
{
title: {
text: chart.nameNonNull()
text: chart.name
},
tooltip:
{
@ -1804,7 +1804,7 @@
options = $.extend(true,
{
title: {
text: chart.nameNonNull()
text: chart.name
},
tooltip:
{
@ -2072,7 +2072,7 @@
options = $.extend(true,
{
title: {
text: chart.nameNonNull()
text: chart.name
},
tooltip:
{
@ -2203,7 +2203,7 @@
options = $.extend(true,
{
title: {
text: chart.nameNonNull()
text: chart.name
},
tooltip:
{
@ -2368,7 +2368,7 @@
options = $.extend(true,
{
title: {
text: chart.nameNonNull()
text: chart.name
},
tooltip:
{
@ -2470,7 +2470,7 @@
options = $.extend(true,
{
title: {
text: chart.nameNonNull()
text: chart.name
},
tooltip:
{
@ -2558,7 +2558,7 @@
options = $.extend(true,
{
title: {
text: chart.nameNonNull()
text: chart.name
},
tooltip:
{
@ -2751,7 +2751,7 @@
options = $.extend(true,
{
title: {
text: chart.nameNonNull()
text: chart.name
},
tooltip:
{
@ -2956,7 +2956,7 @@
options = $.extend(true,
{
title: {
text: chart.nameNonNull()
text: chart.name
},
tooltip:
{
@ -3221,7 +3221,7 @@
options = $.extend(true,
{
title: {
text: chart.nameNonNull()
text: chart.name
},
tooltip:
{
@ -3389,7 +3389,7 @@
options = $.extend(true,
{
title: {
text: chart.nameNonNull()
text: chart.name
},
tooltip:
{
@ -3654,7 +3654,7 @@
//标题样式
title:
{
"text": chart.nameNonNull(),
"text": chart.name,
"show": true,
"color": chartTheme.titleColor,
"backgroundColor": chartTheme.backgroundColor

View File

@ -606,6 +606,8 @@
throw new Error("Dashboard has been initialized");
this._inited = true;
this.charts = (this.charts || []);
this._initListener();
this._initForms();
this._initChartResizeHandler();
@ -653,9 +655,6 @@
*/
dashboardBase._initCharts = function()
{
if(!this.charts)
return;
for(var i=0; i<this.charts.length; i++)
this._initChart(this.charts[i]);
};
@ -686,7 +685,7 @@
{
setTimeout(function()
{
var charts = (thisDashboard.charts || []);
var charts = thisDashboard.charts;
for(var i =0; i<charts.length; i++)
{
@ -835,8 +834,7 @@
//这里不应限制仅能添加未渲染的图表,因为应允许已完成渲染的图表先从看板移除,后续再加入看板
var charts = (this.charts || []);
this.charts = charts.concat(chart);
this.charts = this.charts.concat(chart);
return true;
};
@ -850,7 +848,7 @@
*/
dashboardBase.removeChart = function(chartInfo, doDestory)
{
var newCharts = (this.charts ? [].concat(this.charts) : []);
var newCharts = [].concat(this.charts);
var index = this._chartIndex(newCharts, chartInfo);
if(index < 0)
@ -886,10 +884,8 @@
*/
dashboardBase.resizeAllCharts = function()
{
var charts = (this.charts || []);
for(var i=0; i<charts.length; i++)
charts[i].resize();
for(var i=0; i<this.charts.length; i++)
this.charts[i].resize();
};
/**
@ -1149,7 +1145,7 @@
dashboardBase.isWaitForUpdate = function(chart)
{
return (chart.statusRendered() || chart.statusPreUpdate()
|| (chart.statusUpdated() && chart.updateIntervalNonNull() > -1));
|| (chart.statusUpdated() && chart.updateInterval > -1));
};
/**
@ -1160,7 +1156,7 @@
if(this._doHandlingCharts != true)
return;
var charts = (this.charts || []);
var charts = this.charts;
for(var i=0; i<charts.length; i++)
{
@ -1194,7 +1190,7 @@
}
else
{
var updateInterval = chart.updateIntervalNonNull();
var updateInterval = chart.updateInterval;
var prevUpdateTime = this._chartUpdateTime(chart);
if(prevUpdateTime == null || (prevUpdateTime + updateInterval) <= time)
@ -1861,7 +1857,7 @@
*/
dashboardBase.getAllCharts = function()
{
return (this.charts || []);
return this.charts;
};
// > @deprecated 兼容2.3.0版本的API将在未来版本移除已被dashboardBase.charts取代