/* exported myZtCharts ZtChart */
/* global ZtStackBarChart ZtBarChart ZtPieChart ZtLinesChart ZtAreaChart
ZtContainerChart ZtMultiDimCursorChart
ZtGeographicChart ZtDialChart ZtDisplayChart ZtImageChart ZtLightsChart ZtThermoChart
ZtPyramidDistributionChart ZtWordChart ZtXYZChart ZtParetoChart ZtWaterfallChart ZtRadarChart ZtLayeredBarChart
ZtTreeMapChart ZtTreeMapBarChart ZtStackAreaChart getFilterType
languageConfigurations replaceIconFontWithUnicode replaceIconFontWithCharCode
notifyDraw ZtAsterChart ZtAreaBarChart ZtSunburstChart ZtTreeChart ZtCirclePackChart ZtForceChart
ZtMatrixChart ZtChordChart ZtCalendarChart ZtPyramidChart ZtFunnelChart ZtMekkoChart ZtBCMatrixChart
ZtPCoordsChart ZtVoronoiChart ZtSankeyChart ZtRingPChart ZtECharts decSep milSep
*/
if (typeof myZtCharts == "undefined")
var myZtCharts = {};
// definizione ZtChart
if (typeof(ZtChart) == "undefined") {
window.ZtChart = function (chartConfig, objConfig, propertyName, propertyValue, parent, functionObj, linkObj, mychartid, chartContainer, loadextlibs) {
var oldZTC = (Object.prototype.toString.call(propertyName) === '[object Array]'),
pName,
addData,
addPName,
weburl,
drawWithECharts = false,
render_opts,
draw_opts,
_orgChtConfig;
if (!oldZTC) {
if (chartConfig.drawWithECharts) {
drawWithECharts = chartConfig.drawWithECharts;
weburl = chartConfig.urlReference;
if (!Empty(weburl) && weburl.substr(-1) == '/')
weburl = weburl.slice(0, -1);
if (!loadextlibs) {
initGlobalLibraries(weburl);
loadextlibs = true;
}
parent = chartConfig.parent;
render_opts = chartConfig.render_opts;
draw_opts = chartConfig.draw_opts;
_orgChtConfig = chartConfig.chtConfig;
if (Empty(draw_opts) && !Empty(_orgChtConfig)) {
draw_opts = convertChartConfigInOptions(chartConfig.noDef, _orgChtConfig, propertyName, objConfig);
}
}
else {
this.initialType = chartConfig.graphSettings.chartType;
pName = propertyName.propName;
propertyValue = propertyName.dataset;
parent = propertyName.parent;
functionObj = propertyName.functionObj;
linkObj = propertyName.linkObj;
mychartid = propertyName.chartId;
chartContainer = propertyName.container;
loadextlibs = propertyName.loadLibs;
addData = propertyName.addData;
addPName = propertyName.addPName;
weburl = propertyName.urlReference;
if (!Empty(weburl) && weburl.substr(-1) == '/')
weburl = weburl.slice(0, -1);
}
}
else {
this.initialType = chartConfig.graphSettings.chartType;
pName = propertyName;
}
this.StdChart = null;
this.StdChartCursor = null;
this.stdFormat = null;
this.hoverFormat = null;
this.datetimePict = "YYYY-MM-DD hh:mm:ss";
this.hDatetimePict = "YYYYMMDDhhmmss";
this.menuWrapper = null;
this.fmenuWrapper = null;
this.orgData = propertyValue;
this.enableClick = true;
this.enableLegendClick = true;
this.enableClickEffect = true;
this.enableLegendEffect = true;
this.enableExclude = true;
this.fontsMap = { };
this.ZtChartTransDict = {};
/**** inizializzazione librerie del grafico ****/
if (!loadextlibs)
initGlobalLibraries(weburl);
/**** METODI ESPOSTI DA ZTCHART ****/
this.draw = function (redrawChart, selectedItems) {
if (drawWithECharts) {
// this.StdChart istanza di echart
if (!chartConfig.noDef)
ZtECharts.SetColors(_orgChtConfig, draw_opts);
this.StdChart.setOption(draw_opts);
}
else {
notifyDraw(this.StdChart, 'DrawCallback', redrawChart, selectedItems);
if(this.StdChartCursor && !this.StdChartCursor.drawCursor)
notifyDraw(this.StdChartCursor, 'DrawCallback', redrawChart);
}
}
this.redraw = function (newData, newObjConfig, isFilter) {
notifyDraw(this.StdChart, 'RedrawCallback', newData, newObjConfig, isFilter);
}
this.appendData = function (record) {
notifyDraw(this.StdChart, 'AppendData', record);
}
this.setLanguage = function (lang, m_this) {
if (!lang || languageConfigurations(lang.toLowerCase()) === undefined)
return false;
else {
if (Empty(m_this))
m_this = this.StdChart;
if (m_this) {
m_this.language = lang.toLowerCase();
var mlangobj = languageConfigurations(m_this.language);
m_this.language = lang.toLowerCase();
m_this.localeLangFormat = {};
m_this.localeLangFormat.numberFormat = d3.formatLocale(mlangobj.formatLocale).format;
m_this.localeLangFormat.timeFormat = d3.timeFormatLocale(mlangobj.timeFormatLocale).format;
m_this.localeLangFormat.timeParse = d3.timeParse(mlangobj.timeFormatLocale.dateTime);
m_this.localeLangFormat.csvSeparator = mlangobj.csvSeparator;
m_this.localeLangFormat.formatLocale = mlangobj.formatLocale;
if (m_this.forPJS) {
// htmlunit v.4.1 navigator.language solo en, sistemo i regional settings
if (decSep) decSep = mlangobj.formatLocale.decimal;
if (milSep) milSep = mlangobj.formatLocale.thousands;
}
return true;
}
return false;
}
};
this.setLanguageObj = function (objLang) {
var _this = this.StdChart;
_this.localeLangFormat = {};
_this.localeLangFormat.numberFormat = d3.formatLocale(objLang.formatLocale).format;
_this.localeLangFormat.timeFormat = d3.timeFormatLocale(objLang.timeFormatLocale).format;
_this.localeLangFormat.csvSeparator = objLang.csvSeparator;
};
this.setIsOldVersion = function (value) {
var _this = this.StdChart;
_this.isOLD = value;
}
this.setIsStaticChart = function (value) {
var _this = this.StdChart;
_this.SetIsStaticChart(value);
}
this.getChartId = function () {
var _this = this.StdChart;
return _this.chartId;
}
this.getSVGString = function (imgType, html) {
var _this = this.StdChart,
plot, p0, p1;
var notAvailable = !Empty(d3.select("#" + _this.chartId + "notAv").node());
if (notAvailable && _this.forPJS) {
html = d3.select("#" + _this.chartId + "notAv_div").html();
p0 = html.indexOf("".length);
html = html.replace(/