mdas-jsview-sdk 1.0.11-uat.0 → 1.0.12-uat.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1199,13 +1199,12 @@ const NightSessionTemplate = `
1199
1199
  <div class="company-market-info">
1200
1200
  <span class="night-company-name"></span>
1201
1201
  <span class="market-name"></span>
1202
- <span class="market-mic"></span>
1203
1202
  </div>
1204
1203
  <h1 class="symbol editable-symbol"
1205
1204
  title="Double-click to edit symbol"
1206
1205
  data-original-symbol="">
1207
1206
  </h1>
1208
-
1207
+
1209
1208
  </div>
1210
1209
  <div class="price-section">
1211
1210
  <div class="current-price"></div>
@@ -4415,13 +4414,6 @@ class NightSessionWidget extends BaseWidget {
4415
4414
  marketNameElement.textContent = this.exchangeName || data.exchangeName || '';
4416
4415
  }
4417
4416
 
4418
- // Update MIC (Market Identifier Code)
4419
- const marketMicElement = this.container.querySelector('.market-mic');
4420
- if (marketMicElement) {
4421
- const micValue = this.mic || data.mic || '';
4422
- marketMicElement.textContent = micValue;
4423
- }
4424
-
4425
4417
  // Update price
4426
4418
  const currentPriceElement = this.container.querySelector('.current-price');
4427
4419
  if (currentPriceElement) {
@@ -37500,6 +37492,10 @@ class IntradayChartWidget extends BaseWidget {
37500
37492
 
37501
37493
  // Symbol editor
37502
37494
  this.symbolEditor = null;
37495
+
37496
+ // Lazy loading cache for 5D data
37497
+ this.cached5DData = null;
37498
+ this.is5DDataLoading = false;
37503
37499
  this.createWidgetStructure();
37504
37500
  this.setupSymbolEditor();
37505
37501
  this.initialize();
@@ -37601,6 +37597,10 @@ class IntradayChartWidget extends BaseWidget {
37601
37597
  this.chartData = null;
37602
37598
  this.livePrice = null;
37603
37599
 
37600
+ // Clear cached 5D data for old symbol
37601
+ this.cached5DData = null;
37602
+ this.is5DDataLoading = false;
37603
+
37604
37604
  // Update internal symbol
37605
37605
  this.symbol = upperSymbol;
37606
37606
 
@@ -37751,7 +37751,13 @@ class IntradayChartWidget extends BaseWidget {
37751
37751
  throw new Error('API service not available');
37752
37752
  }
37753
37753
 
37754
- // FALLBACK LOGIC: Try to find most recent available data
37754
+ // For 5D chart: Load data from multiple days (rangeback 0-5)
37755
+ if (this.rangeBack === 5) {
37756
+ await this.load5DayChartData(apiService);
37757
+ return;
37758
+ }
37759
+
37760
+ // FALLBACK LOGIC: Try to find most recent available data (for 1D)
37755
37761
  const MAX_LOOKBACK_DAYS = 7;
37756
37762
  let attemptRangeBack = this.rangeBack;
37757
37763
  let dataFound = false;
@@ -37840,6 +37846,9 @@ class IntradayChartWidget extends BaseWidget {
37840
37846
  await this.startAutoRefresh();
37841
37847
  // Subscribe to live price updates
37842
37848
  this.subscribeToLivePrice();
37849
+
37850
+ // LAZY LOADING: Preload 5D data in the background after 1D loads
37851
+ this.preload5DDataInBackground();
37843
37852
  } else {
37844
37853
  // Historical data or fallback - don't refresh
37845
37854
  this.stopAutoRefresh();
@@ -37867,6 +37876,159 @@ class IntradayChartWidget extends BaseWidget {
37867
37876
  this.showError(errorMessage);
37868
37877
  }
37869
37878
  }
37879
+ async load5DayChartData(apiService) {
37880
+ try {
37881
+ // Check if we have cached 5D data
37882
+ if (this.cached5DData) {
37883
+ if (this.debug) {
37884
+ console.log('[IntradayChartWidget] Using cached 5D data');
37885
+ }
37886
+
37887
+ // Use cached data
37888
+ this.chartData = this.cached5DData;
37889
+ this.renderChart();
37890
+ this.updateStats();
37891
+ this.hideLoading();
37892
+
37893
+ // Don't auto-refresh for 5D chart
37894
+ this.stopAutoRefresh();
37895
+ return;
37896
+ }
37897
+
37898
+ // No cached data, load it now
37899
+ const combinedData = await this.fetch5DayData(apiService);
37900
+
37901
+ // Process the combined data
37902
+ this.chartData = new IntradayChartModel(combinedData);
37903
+ if (this.chartData.dataPoints.length === 0) {
37904
+ throw new Error(`No valid data points for ${this.symbol}`);
37905
+ }
37906
+
37907
+ // Cache the processed data
37908
+ this.cached5DData = this.chartData;
37909
+ this.renderChart();
37910
+ this.updateStats();
37911
+ this.hideLoading();
37912
+ if (this.debug) {
37913
+ console.log(`[IntradayChartWidget] 5D chart loaded with ${this.chartData.dataPoints.length} data points`);
37914
+ }
37915
+
37916
+ // Don't auto-refresh for 5D chart
37917
+ this.stopAutoRefresh();
37918
+ } catch (error) {
37919
+ console.error('[IntradayChartWidget] Error loading 5D chart data:', error);
37920
+ throw error; // Re-throw to be caught by parent loadChartData
37921
+ }
37922
+ }
37923
+ async fetch5DayData(apiService) {
37924
+ const DAYS_TO_COLLECT = 5;
37925
+ const MAX_RANGEBACK_ATTEMPTS = 7; // API limit: maximum 7 rangeback
37926
+
37927
+ if (this.debug) {
37928
+ console.log('[IntradayChartWidget] Fetching 5D chart data with parallel requests (API limit: rangeback 0-6)');
37929
+ }
37930
+
37931
+ // OPTIMIZATION: Query all rangeback values in parallel (0-6)
37932
+ const rangebackPromises = [];
37933
+ for (let rb = 0; rb < MAX_RANGEBACK_ATTEMPTS; rb++) {
37934
+ rangebackPromises.push(apiService.getIntradayChart(this.source, this.symbol, rb).then(response => {
37935
+ // Extract data array from response
37936
+ let dataArray = response;
37937
+ if (response && response.data && Array.isArray(response.data)) {
37938
+ dataArray = response.data;
37939
+ }
37940
+ return {
37941
+ rangeBack: rb,
37942
+ data: dataArray
37943
+ };
37944
+ }).catch(error => {
37945
+ // If a request fails, return null so we can filter it out
37946
+ if (this.debug) {
37947
+ console.warn(`[IntradayChartWidget] Request failed for rangeback ${rb}:`, error);
37948
+ }
37949
+ return {
37950
+ rangeBack: rb,
37951
+ data: null
37952
+ };
37953
+ }));
37954
+ }
37955
+
37956
+ // Wait for all parallel requests to complete
37957
+ const results = await Promise.all(rangebackPromises);
37958
+ if (this.debug) {
37959
+ console.log('[IntradayChartWidget] All parallel requests completed');
37960
+ }
37961
+
37962
+ // Filter out empty/null responses and collect valid days
37963
+ const collectedDays = results.filter(result => {
37964
+ const isValid = result.data && Array.isArray(result.data) && result.data.length > 0;
37965
+ if (this.debug) {
37966
+ if (isValid) {
37967
+ console.log(`[IntradayChartWidget] Rangeback ${result.rangeBack}: ${result.data.length} data points`);
37968
+ } else {
37969
+ console.log(`[IntradayChartWidget] Rangeback ${result.rangeBack}: No data (skipped)`);
37970
+ }
37971
+ }
37972
+ return isValid;
37973
+ }).slice(0, DAYS_TO_COLLECT); // Take only the first 5 days with data
37974
+
37975
+ if (collectedDays.length === 0) {
37976
+ throw new Error(`No intraday data available for ${this.symbol} in the past ${MAX_RANGEBACK_ATTEMPTS} days`);
37977
+ }
37978
+ if (this.debug) {
37979
+ console.log(`[IntradayChartWidget] Collected ${collectedDays.length}/${DAYS_TO_COLLECT} days of data`);
37980
+ if (collectedDays.length < DAYS_TO_COLLECT) {
37981
+ console.log(`[IntradayChartWidget] Note: Only ${collectedDays.length} days available within API limit (rangeback 0-6)`);
37982
+ }
37983
+ }
37984
+
37985
+ // Combine all collected days into a single array (oldest to newest)
37986
+ const combinedData = [];
37987
+ for (let i = collectedDays.length - 1; i >= 0; i--) {
37988
+ combinedData.push(...collectedDays[i].data);
37989
+ }
37990
+ if (this.debug) {
37991
+ console.log(`[IntradayChartWidget] Combined ${combinedData.length} total data points from ${collectedDays.length} days`);
37992
+ }
37993
+ return combinedData;
37994
+ }
37995
+ preload5DDataInBackground() {
37996
+ // Prevent multiple simultaneous preloads
37997
+ if (this.is5DDataLoading || this.cached5DData) {
37998
+ return;
37999
+ }
38000
+ this.is5DDataLoading = true;
38001
+ if (this.debug) {
38002
+ console.log('[IntradayChartWidget] Starting background preload of 5D data...');
38003
+ }
38004
+
38005
+ // Run in background without blocking
38006
+ setTimeout(async () => {
38007
+ try {
38008
+ const apiService = this.wsManager.getApiService();
38009
+ if (!apiService) {
38010
+ if (this.debug) {
38011
+ console.log('[IntradayChartWidget] API service not available for preload');
38012
+ }
38013
+ return;
38014
+ }
38015
+ const combinedData = await this.fetch5DayData(apiService);
38016
+
38017
+ // Create and cache the model
38018
+ const chartData = new IntradayChartModel(combinedData);
38019
+ this.cached5DData = chartData;
38020
+ if (this.debug) {
38021
+ console.log(`[IntradayChartWidget] ✓ Background preload complete: ${chartData.dataPoints.length} data points cached`);
38022
+ }
38023
+ } catch (error) {
38024
+ if (this.debug) {
38025
+ console.warn('[IntradayChartWidget] Background preload failed:', error);
38026
+ }
38027
+ } finally {
38028
+ this.is5DDataLoading = false;
38029
+ }
38030
+ }, 1000); // Wait 1 second after 1D loads before starting preload
38031
+ }
37870
38032
  subscribeToLivePrice() {
37871
38033
  // Unsubscribe from previous subscription if any
37872
38034
  if (this.unsubscribe) {
@@ -38415,10 +38577,12 @@ class IntradayChartWidget extends BaseWidget {
38415
38577
  autoSkip: true,
38416
38578
  maxRotation: 0,
38417
38579
  minRotation: 0,
38418
- callback: (value, index) => {
38580
+ callback: (value, index, ticks) => {
38419
38581
  if (this.rangeBack > 0) {
38420
- // For multi-day charts with linear scale, show actual time from data point
38421
- const point = validDataPoints[index];
38582
+ // For multi-day charts with linear scale
38583
+ // value is the x-value (index in data array), not the tick index
38584
+ const dataIndex = Math.round(value);
38585
+ const point = validDataPoints[dataIndex];
38422
38586
  if (point) {
38423
38587
  const date = new Date(point.time);
38424
38588
  return date.toLocaleString('en-US', {