instanceManager.setFn(function(layout) { var fn = function(legendSetId) { var el = uiManager.getUpdateComponent().body.id; var response = layout.getResponse(); var extraOptions = legendSetId ? { legendSet: appManager.getLegendSetById(legendSetId), } : undefined; var { chart } = createChart(response, layout, el, extraOptions); // reg uiManager.reg(chart, 'chart'); // mask uiManager.unmask(); // statistics instanceManager.postDataStatistics(); }; // legend set if (layout.doLegendSet()) { appManager.getLegendSetIdByDxId(layout.getFirstDxId(), function(legendSetId) { fn(legendSetId); }); } else { fn(); } });
var fn = function(legendSetId) { var el = _layout.el; var element = document.getElementById(el); var response = _layout.getResponse(); extraOptions.legendSet = appManager.getLegendSetById(legendSetId); extraOptions.dashboard = instanceManager.dashboard; var { chart } = createChart(response, _layout, el, extraOptions); // reg uiManager.reg(chart, 'chart'); // dashboard item resize element.setViewportWidth = function(width) { chart.setSize(width, undefined, { duration: 50 }); }; element.setViewportHeight = function(height) { chart.setSize(undefined, height, { duration: 50 }); }; element.setViewportSize = function(width, height) { chart.setSize(width, height, { duration: 50 }); }; // mask uiManager.unmask(); };
// Year over year special handling function apiFetchAnalyticsForYearOverYear(current, options) { d2init({ baseUrl: appManager.getApiPath() }); var d2; var yearlySeriesLabels = []; return getInstance() .then(d2Instance => { d2 = d2Instance; }) .then(() => { let yearlySeriesReq = new d2.analytics.request() .addPeriodDimension(current.yearlySeries) .withSkipData(true) .withSkipMeta(false) .withIncludeMetadataDetails(true); if (options.relativePeriodDate) { yearlySeriesReq = yearlySeriesReq.withRelativePeriodDate( options.relativePeriodDate ); } return d2.analytics.aggregate.fetch(yearlySeriesReq); }) .then(yearlySeriesRes => { const requests = []; const now = new Date(); const currentDay = ('' + now.getDate()).padStart(2, 0); const currentMonth = ('' + (now.getMonth() + 1)).padStart(2, 0); yearlySeriesRes.metaData.dimensions['pe'].forEach(period => { yearlySeriesLabels.push(yearlySeriesRes.metaData.items[period].name); const startDate = `${period}-${currentMonth}-${currentDay}`; const req = new d2.analytics.request() .fromModel(current) .withParameters(options) .withRelativePeriodDate(startDate); requests.push(d2.analytics.aggregate.get(req)); }); return Promise.all(requests); }) .then(responses => { return Promise.resolve({ responses: responses.map(res => new d2.analytics.response(res)), yearlySeriesLabels, }); }) .catch(e => console.log(e)); }
instanceManager.setFn(function(_layout) { if (!util.dom.validateTargetDiv(_layout.el)) { return; } var fn = function(legendSetId) { var el = _layout.el; var element = document.getElementById(el); var response = _layout.getResponse(); extraOptions.legendSet = appManager.getLegendSetById(legendSetId); extraOptions.dashboard = instanceManager.dashboard; var { chart } = createChart(response, _layout, el, extraOptions); // reg uiManager.reg(chart, 'chart'); // dashboard item resize element.setViewportWidth = function(width) { chart.setSize(width, undefined, { duration: 50 }); }; element.setViewportHeight = function(height) { chart.setSize(undefined, height, { duration: 50 }); }; element.setViewportSize = function(width, height) { chart.setSize(width, height, { duration: 50 }); }; // mask uiManager.unmask(); }; // legend set if (_layout.doLegendSet()) { appManager.getLegendSetIdByDxId(_layout.getFirstDxId(), function(legendSetId) { fn(legendSetId); }); } else { fn(); } });
var fn = function(legendSetId) { var el = uiManager.getUpdateComponent().body.id; var response = layout.getResponse(); var extraOptions = legendSetId ? { legendSet: appManager.getLegendSetById(legendSetId), } : undefined; var { chart } = createChart(response, layout, el, extraOptions); // reg uiManager.reg(chart, 'chart'); // mask uiManager.unmask(); // statistics instanceManager.postDataStatistics(); };
refs.optionConfig = optionConfig; // period config var periodConfig = new config.PeriodConfig(); refs.periodConfig = periodConfig; // chart config var chartConfig = new config.ChartConfig(); refs.chartConfig = chartConfig; // ui config var uiConfig = new config.UiConfig(); refs.uiConfig = uiConfig; // app manager var appManager = new manager.AppManager(refs); appManager.sessionName = 'chart'; appManager.apiVersion = 31; refs.appManager = appManager; // calendar manager var calendarManager = new manager.CalendarManager(refs); refs.calendarManager = calendarManager; // request manager var requestManager = new manager.RequestManager(refs); refs.requestManager = requestManager; // i18n manager var i18nManager = new manager.I18nManager(refs); refs.i18nManager = i18nManager;
refs.dimensionConfig = dimensionConfig; // option config var optionConfig = new config.OptionConfig(); refs.optionConfig = optionConfig; // period config var periodConfig = new config.PeriodConfig(); refs.periodConfig = periodConfig; // chart config var chartConfig = new config.ChartConfig(); refs.chartConfig = chartConfig; // app manager var appManager = new manager.AppManager(refs); appManager.apiVersion = 31; refs.appManager = appManager; // calendar manager var calendarManager = new manager.CalendarManager(refs); refs.calendarManager = calendarManager; // request manager var requestManager = new manager.RequestManager(refs); refs.requestManager = requestManager; // i18n manager var i18nManager = new manager.I18nManager(refs); refs.i18nManager = i18nManager;