{"id":469519,"date":"2025-08-04T15:01:14","date_gmt":"2025-08-04T15:01:14","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=469519"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=469519","title":{"rendered":"<span>\u0418\u043d\u0442\u0435\u0440\u0430\u043a\u0442\u0438\u0432\u043d\u0430\u044f \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0441\u043f\u043e\u0440\u0442\u0438\u0432\u043d\u044b\u0445 \u043a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442\u043e\u0432: \u0447\u0442\u043e \u0443\u0434\u0430\u043b\u043e\u0441\u044c, \u0430 \u0447\u0442\u043e \u043d\u0435\u0442<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<blockquote>\n<p> \u041f\u043e\u0442\u044f\u043d\u0443\u043b live-\u0434\u0430\u043d\u043d\u044b\u0435 \u0441 mygameodds co, \u0441\u043e\u0431\u0440\u0430\u043b real-time \u0433\u0440\u0430\u0444\u0438\u043a\u0438 \u043d\u0430 D3.js, \u0441\u0442\u043e\u043b\u043a\u043d\u0443\u043b\u0441\u044f \u0441 \u0434\u0438\u043a\u0438\u043c \u0445\u0430\u043e\u0441\u043e\u043c \u0432 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0435 \u0434\u0430\u043d\u043d\u044b\u0445, \u0440\u0435\u0448\u0438\u043b \u0447\u0435\u0440\u0435\u0437 \u043d\u043e\u0440\u043c\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e, \u043d\u043e \u043f\u0440\u043e\u0432\u0430\u043b\u0438\u043b\u0441\u044f \u0441 \u0430\u0434\u0430\u043f\u0442\u0438\u0432\u043e\u043c.<\/p>\n<\/blockquote>\n<h4>\u0426\u0435\u043b\u044c<\/h4>\n<p>\u041f\u043e\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u0438\u043d\u0442\u0435\u0440\u0430\u043a\u0442\u0438\u0432\u043d\u044b\u0439 \u0434\u0430\u0448\u0431\u043e\u0440\u0434, \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u044e\u0449\u0438\u0439 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u0441\u043f\u043e\u0440\u0442\u0438\u0432\u043d\u044b\u0445 \u043a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442\u043e\u0432 \u0432 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u043c \u0432\u0440\u0435\u043c\u0435\u043d\u0438. \u0410\u043d\u0430\u043b\u043e\u0433 \u0441\u0438\u0441\u0442\u0435\u043c \u043c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u043d\u0433\u0430, \u0442\u043e\u043b\u044c\u043a\u043e \u0432\u043c\u0435\u0441\u0442\u043e \u043c\u0435\u0442\u0440\u0438\u043a \u2014 \u043b\u0430\u0439\u0432-\u043a\u044d\u0444\u044b \u0441 \u0431\u0443\u043a\u043c\u0435\u043a\u0435\u0440\u0441\u043a\u043e\u0433\u043e API.<\/p>\n<hr\/>\n<h4>\u0410\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0430<\/h4>\n<ul>\n<li>\n<p>\u0418\u0441\u0442\u043e\u0447\u043d\u0438\u043a \u0434\u0430\u043d\u043d\u044b\u0445: <a href=\"http:\/\/mygameodds.co\" rel=\"noopener noreferrer nofollow\">mygameodds.co<\/a><\/p>\n<\/li>\n<li>\n<p>\u0421\u0442\u0435\u043a:<\/p>\n<\/li>\n<li>\n<p>D3.js (\u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f)<\/p>\n<\/li>\n<li>\n<p>WebSocket (\u0441\u0442\u0440\u0438\u043c\u0438\u043d\u0433)<\/p>\n<\/li>\n<li>\n<p>TypeScript (\u0432\u0441\u044f \u043b\u043e\u0433\u0438\u043a\u0430)<\/p>\n<\/li>\n<li>\n<p>Vite + React (\u043e\u0431\u0432\u044f\u0437\u043a\u0430, \u0440\u0435\u043d\u0434\u0435\u0440)<\/p>\n<\/li>\n<\/ul>\n<hr\/>\n<h4>\u0420\u0430\u0431\u043e\u0442\u0430 \u0441 API<\/h4>\n<p>\u0414\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 \u043a <a href=\"http:\/\/mygameodds.co\" rel=\"noopener noreferrer nofollow\">mygameodds.co<\/a> \u043d\u0435 \u0431\u044b\u043b\u043e \u2014 \u0432\u0441\u0451 \u0441\u043e\u0431\u0438\u0440\u0430\u043b\u043e\u0441\u044c \u0447\u0435\u0440\u0435\u0437 \u0438\u043d\u0441\u043f\u0435\u043a\u0446\u0438\u044e \u0441\u0435\u0442\u0438 \u0438 reverse engineering.<\/p>\n<h4>\ud83d\udce1 \u041f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u043a WebSocket<\/h4>\n<pre><code>const socket = new WebSocket(\"wss:\/\/stream.mygameodds.co\/live\");  socket.onmessage = (event) =&gt; {   const data = JSON.parse(event.data);   handleIncomingEvent(data); }; <\/code><\/pre>\n<p>\u0421\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f \u043f\u0440\u0438\u0445\u043e\u0434\u044f\u0442 \u043f\u0430\u0447\u043a\u0430\u043c\u0438, \u0432 \u0444\u043e\u0440\u043c\u0430\u0442\u0435:<\/p>\n<pre><code>{   \"match_id\": 1234,   \"event\": \"odds_update\",   \"markets\": [     {       \"type\": \"match_winner\",       \"odds\": {         \"home\": 1.72,         \"draw\": 3.1,         \"away\": 4.5       }     }   ],   \"timestamp\": \"2025-08-03T14:22:01Z\" } <\/code><\/pre>\n<p>\u041f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u2014 \u043d\u0438\u043a\u0430\u043a\u043e\u0439 \u0441\u0442\u0430\u0431\u0438\u043b\u044c\u043d\u043e\u0441\u0442\u0438. \u0412 \u0434\u0440\u0443\u0433\u0438\u0445 \u043c\u0430\u0442\u0447\u0430\u0445:<\/p>\n<ul>\n<li>\n<p>odds = \u043c\u0430\u0441\u0441\u0438\u0432 \u0441 \u043a\u043b\u044e\u0447\u0430\u043c\u0438 &#171;name&#187; \/ &#171;value&#187;<\/p>\n<\/li>\n<li>\n<p>\u0412\u0440\u0435\u043c\u044f \u2014 \u0442\u043e\u043b\u044c\u043a\u043e updated_at, \u0438\u043d\u043e\u0433\u0434\u0430 \u0432 \u0444\u043e\u0440\u043c\u0430\u0442\u0435 Unix<\/p>\n<\/li>\n<li>\n<p>\u041d\u0430\u0437\u0432\u0430\u043d\u0438\u044f \u0438\u0441\u0445\u043e\u0434\u043e\u0432 (&#171;team1&#187;, &#171;x&#187;, &#171;team2&#187;)<\/p>\n<\/li>\n<\/ul>\n<hr\/>\n<h4>\u041d\u043e\u0440\u043c\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445<\/h4>\n<p>\u0427\u0442\u043e\u0431\u044b \u0443\u043d\u0438\u0444\u0438\u0446\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u0434\u043b\u044f \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438, \u043d\u0430\u043f\u0438\u0441\u0430\u043b \u043c\u043e\u0434\u0443\u043b\u044c normalizeOdds(data: RawEvent): NormalizedOdds[].<\/p>\n<h4>\ud83d\udd04 \u041f\u0440\u0438\u043c\u0435\u0440 \u043d\u043e\u0440\u043c\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440\u0430<\/h4>\n<pre><code>function normalizeOdds(event: RawEvent): NormalizedOdds[] {   const ts = new Date(event.timestamp || event.updated_at || Date.now()).toISOString();      return event.markets.map(m =&gt; {     const odds = m.odds || {};          const entries = Array.isArray(odds)       ? Object.fromEntries(odds.map((o: any) =&gt; [o.name.toLowerCase(), o.value]))       : odds;      return {       matchId: event.match_id,       type: m.type,       timestamp: ts,       home: entries.home || entries.team1 || null,       draw: entries.draw || entries.x || null,       away: entries.away || entries.team2 || null,     };   }); } <\/code><\/pre>\n<p>\u0412\u044b\u0445\u043e\u0434:<\/p>\n<pre><code>{   matchId: 1234,   type: 'match_winner',   timestamp: '2025-08-03T14:22:01Z',   home: 1.72,   draw: 3.1,   away: 4.5 } <\/code><\/pre>\n<hr\/>\n<h4>\u0425\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435 \u0438 \u043f\u043e\u0442\u043e\u043a \u0434\u0430\u043d\u043d\u044b\u0445<\/h4>\n<p>\u0421\u0434\u0435\u043b\u0430\u043b Map&lt;matchId, MatchState&gt; \u2014 \u0445\u0440\u0430\u043d\u0438\u043c \u0438\u0441\u0442\u043e\u0440\u0438\u044e \u043a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442\u043e\u0432 \u043f\u043e \u043c\u0430\u0442\u0447\u0430\u043c.<\/p>\n<p> \u041f\u0440\u0438 \u043a\u0430\u0436\u0434\u043e\u043c odds_update \u043f\u0443\u0448\u0438\u043c \u043d\u043e\u0432\u044b\u0435 \u0442\u043e\u0447\u043a\u0438 \u0432 \u043c\u0430\u0441\u0441\u0438\u0432 \u0438 \u0442\u0440\u0438\u0433\u0433\u0435\u0440\u0438\u043c requestAnimationFrame \u043d\u0430 \u0440\u0435\u0440\u0435\u043d\u0434\u0435\u0440.<\/p>\n<h4>\ud83e\udde0 \u041f\u0440\u043e\u0441\u0442\u0430\u044f \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430:<\/h4>\n<pre><code>interface MatchState {   history: {     timestamp: string     home: number | null     draw: number | null     away: number | null   }[] } <\/code><\/pre>\n<hr\/>\n<h4>\u0412\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043d\u0430 D3.js<\/h4>\n<h4>\u0417\u0430\u0434\u0430\u0447\u0438:<\/h4>\n<ul>\n<li>\n<p>\u041d\u0430\u0440\u0438\u0441\u043e\u0432\u0430\u0442\u044c \u0442\u0440\u0438 \u043b\u0438\u043d\u0438\u0438 (home, draw, away)<\/p>\n<\/li>\n<li>\n<p>\u041e\u0431\u043d\u043e\u0432\u043b\u044f\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u0432 real-time<\/p>\n<\/li>\n<li>\n<p>\u0414\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0437\u0443\u043c \u0438 pan (D3 Zoom Behavior)<\/p>\n<\/li>\n<\/ul>\n<h4>\ud83d\udcc8 \u041e\u0442\u0440\u0438\u0441\u043e\u0432\u043a\u0430 \u0433\u0440\u0430\u0444\u0438\u043a\u0430<\/h4>\n<pre><code>const svg = d3.select('#chart')   .attr('width', width)   .attr('height', height);  const x = d3.scaleTime().range([0, width]); const y = d3.scaleLinear().range([height, 0]);  const line = d3.line&lt;OddsPoint&gt;()   .x(d =&gt; x(new Date(d.timestamp)))   .y(d =&gt; y(d.home));  svg.append(\"path\")   .datum(match.history)   .attr(\"class\", \"line-home\")   .attr(\"d\", line); <\/code><\/pre>\n<p>\u041a\u0430\u0436\u0434\u0430\u044f \u043b\u0438\u043d\u0438\u044f \u0440\u0438\u0441\u0443\u0435\u0442\u0441\u044f \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e (\u0442\u0440\u0438 path \u043f\u043e \u043e\u0434\u043d\u043e\u043c\u0443 \u043d\u0430 \u0438\u0441\u0445\u043e\u0434).<\/p>\n<p>\u041e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 \u0434\u0435\u043b\u0430\u044e \u0447\u0435\u0440\u0435\u0437 join().attr(&#171;d&#187;, line) \u0432\u043d\u0443\u0442\u0440\u0438 RAF.<\/p>\n<hr\/>\n<h4>\u041f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u0441 \u0430\u0434\u0430\u043f\u0442\u0438\u0432\u043e\u043c<\/h4>\n<p>\u041d\u0430 \u0434\u0435\u0441\u043a\u0442\u043e\u043f\u0435 \u0432\u0441\u0451 \u043a\u0440\u0443\u0442\u043e. \u041d\u043e&#8230;<\/p>\n<ul>\n<li>\n<p>\u041d\u0430 \u043c\u043e\u0431\u0438\u043b\u043a\u0435 \u0437\u0443\u043c \u043b\u043e\u043c\u0430\u0435\u0442\u0441\u044f: \u043f\u0430\u043b\u044c\u0446\u044b \u0441\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u044e\u0442 \u043d\u0435\u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u043e, \u0441\u043e\u0431\u044b\u0442\u0438\u044f touchmove \u043a\u043e\u043d\u0444\u043b\u0438\u043a\u0442\u0443\u044e\u0442 \u0441 pan<\/p>\n<\/li>\n<li>\n<p>SVG \u043d\u0435 \u0432\u043b\u0435\u0437\u0430\u0435\u0442 \u043f\u043e \u0448\u0438\u0440\u0438\u043d\u0435, \u0433\u043e\u0440\u0438\u0437\u043e\u043d\u0442\u0430\u043b\u044c\u043d\u044b\u0439 \u0441\u043a\u0440\u043e\u043b\u043b \u043d\u0435 \u043f\u043e\u043c\u043e\u0433\u0430\u0435\u0442<\/p>\n<\/li>\n<li>\n<p>FPS \u043f\u0430\u0434\u0430\u0435\u0442 \u043f\u0440\u0438 200+ \u0442\u043e\u0447\u043a\u0430\u0445 \u043d\u0430 \u0433\u0440\u0430\u0444\u0438\u043a\u0435<\/p>\n<\/li>\n<\/ul>\n<p>\u0420\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u044e \u043f\u0435\u0440\u0435\u0445\u043e\u0434 \u043d\u0430:<\/p>\n<ul>\n<li>\n<p>Canvas \u2014 \u0440\u0430\u0434\u0438 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438<\/p>\n<\/li>\n<li>\n<p>WebGL (Pixi.js) \u2014 \u0435\u0441\u043b\u0438 \u0433\u0440\u0430\u0444\u0438\u043a\u043e\u0432 \u0431\u0443\u0434\u0435\u0442 \u043c\u043d\u043e\u0433\u043e<\/p>\n<\/li>\n<\/ul>\n<hr\/>\n<h4>\u0427\u0442\u043e \u043f\u043b\u0430\u043d\u0438\u0440\u0443\u044e \u0434\u0430\u043b\u044c\u0448\u0435<\/h4>\n<ul>\n<li>\n<p>\u041f\u0435\u0440\u0435\u0432\u0435\u0441\u0442\u0438 \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u043d\u0430 Canvas<\/p>\n<\/li>\n<li>\n<p>\u0421\u0434\u0435\u043b\u0430\u0442\u044c \u043e\u0442\u043b\u043e\u0436\u0435\u043d\u043d\u0443\u044e \u043e\u0442\u0440\u0438\u0441\u043e\u0432\u043a\u0443 (debounce + batch updates)<\/p>\n<\/li>\n<li>\n<p>\u0414\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0444\u0438\u043b\u044c\u0442\u0440\u044b \u043f\u043e \u043c\u0430\u0440\u043a\u0435\u0442\u0443<\/p>\n<\/li>\n<li>\n<p>\u041f\u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u0442\u044c SSR \u0434\u043b\u044f \u0441\u043d\u0438\u0436\u0435\u043d\u0438\u044f TTI (\u0435\u0441\u043b\u0438 \u0440\u0435\u043d\u0434\u0435\u0440\u0438\u0442\u044c \u0441\u0442\u0430\u0442\u0438\u043a\u0443)<\/p>\n<\/li>\n<\/ul>\n<hr\/>\n<h4>\u0418\u0442\u043e\u0433\u0438<\/h4>\n<p>\u0423\u0434\u0430\u043b\u043e\u0441\u044c:<\/p>\n<p>\u2705 \u041f\u0440\u043e\u0442\u044f\u043d\u0443\u0442\u044c live WebSocket-\u0434\u0430\u043d\u043d\u044b\u0435<\/p>\n<p> \u2705 \u041f\u0440\u0438\u0432\u0435\u0441\u0442\u0438 \u0445\u0430\u043e\u0442\u0438\u0447\u043d\u044b\u0435 odds \u043a \u0435\u0434\u0438\u043d\u043e\u043c\u0443 \u0444\u043e\u0440\u043c\u0430\u0442\u0443<\/p>\n<p> \u2705 \u0421\u043e\u0431\u0440\u0430\u0442\u044c \u0438\u043d\u0442\u0435\u0440\u0430\u043a\u0442\u0438\u0432\u043d\u044b\u0439 \u0433\u0440\u0430\u0444\u0438\u043a \u043d\u0430 D3.js<\/p>\n<p> \u2705 \u041f\u043e\u043a\u0430\u0437\u0430\u0442\u044c \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u0435 \u0434\u0432\u0438\u0436\u0435\u043d\u0438\u044f \u043a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442\u043e\u0432 \u043f\u043e \u043c\u0430\u0442\u0447\u0430\u043c<\/p>\n<p>\u041f\u0440\u043e\u0432\u0430\u043b\u0438\u043b\u043e\u0441\u044c:<\/p>\n<p>\u274c \u041c\u043e\u0431\u0438\u043b\u044c\u043d\u044b\u0439 UX (\u0437\u0443\u043c\/\u043f\u0435\u0440\u0435\u0445\u043e\u0434\u044b)<\/p>\n<p> \u274c \u041d\u0435\u0442 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0438 \u0441\u043b\u043e\u0436\u043d\u044b\u0445 \u043c\u0430\u0440\u043a\u0435\u0442\u043e\u0432 (\u0430\u0437\u0438\u0430\u0442\u0441\u043a\u0438\u0435 \u0444\u043e\u0440\u044b, \u0442\u043e\u0442\u0430\u043b\u044b)<\/p>\n<p> \u274c \u041f\u0435\u0440\u0444\u043e\u0440\u043c\u0430\u043d\u0441 \u043f\u0430\u0434\u0430\u0435\u0442 \u043d\u0430 \u0431\u043e\u043b\u044c\u0448\u0438\u0445 \u0432\u044b\u0431\u043e\u0440\u043a\u0430\u0445<\/p>\n<hr\/>\n<h4>P.S.<\/h4>\n<p>\u0415\u0441\u043b\u0438 \u0443 \u043a\u043e\u0433\u043e-\u0442\u043e \u0431\u044b\u043b \u043e\u043f\u044b\u0442 \u043f\u0435\u0440\u0435\u043d\u043e\u0441\u0430 \u043f\u043e\u0434\u043e\u0431\u043d\u044b\u0445 \u0433\u0440\u0430\u0444\u0438\u043a\u043e\u0432 \u0441 SVG \u043d\u0430 Canvas \u0438\u043b\u0438 WebGL \u2014 \u043f\u043e\u0434\u0435\u043b\u0438\u0442\u0435\u0441\u044c \u0441\u0441\u044b\u043b\u043a\u0430\u043c\u0438 \/ \u0434\u0435\u043c\u043a\u0430\u043c\u0438 \/ \u043f\u043e\u0434\u0445\u043e\u0434\u0430\u043c\u0438. \u0413\u043e\u0442\u043e\u0432 open-source-\u0438\u0442\u044c \u0447\u0430\u0441\u0442\u044c \u0440\u0435\u0448\u0435\u043d\u0438\u0439, \u0435\u0441\u043b\u0438 \u0431\u0443\u0434\u0435\u0442 \u0438\u043d\u0442\u0435\u0440\u0435\u0441.<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/933852\/\"> https:\/\/habr.com\/ru\/articles\/933852\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<blockquote>\n<p> \u041f\u043e\u0442\u044f\u043d\u0443\u043b live-\u0434\u0430\u043d\u043d\u044b\u0435 \u0441 mygameodds co, \u0441\u043e\u0431\u0440\u0430\u043b real-time \u0433\u0440\u0430\u0444\u0438\u043a\u0438 \u043d\u0430 D3.js, \u0441\u0442\u043e\u043b\u043a\u043d\u0443\u043b\u0441\u044f \u0441 \u0434\u0438\u043a\u0438\u043c \u0445\u0430\u043e\u0441\u043e\u043c \u0432 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0435 \u0434\u0430\u043d\u043d\u044b\u0445, \u0440\u0435\u0448\u0438\u043b \u0447\u0435\u0440\u0435\u0437 \u043d\u043e\u0440\u043c\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e, \u043d\u043e \u043f\u0440\u043e\u0432\u0430\u043b\u0438\u043b\u0441\u044f \u0441 \u0430\u0434\u0430\u043f\u0442\u0438\u0432\u043e\u043c.<\/p>\n<\/blockquote>\n<h4>\u0426\u0435\u043b\u044c<\/h4>\n<p>\u041f\u043e\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u0438\u043d\u0442\u0435\u0440\u0430\u043a\u0442\u0438\u0432\u043d\u044b\u0439 \u0434\u0430\u0448\u0431\u043e\u0440\u0434, \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u044e\u0449\u0438\u0439 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u0441\u043f\u043e\u0440\u0442\u0438\u0432\u043d\u044b\u0445 \u043a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442\u043e\u0432 \u0432 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u043c \u0432\u0440\u0435\u043c\u0435\u043d\u0438. \u0410\u043d\u0430\u043b\u043e\u0433 \u0441\u0438\u0441\u0442\u0435\u043c \u043c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u043d\u0433\u0430, \u0442\u043e\u043b\u044c\u043a\u043e \u0432\u043c\u0435\u0441\u0442\u043e \u043c\u0435\u0442\u0440\u0438\u043a \u2014 \u043b\u0430\u0439\u0432-\u043a\u044d\u0444\u044b \u0441 \u0431\u0443\u043a\u043c\u0435\u043a\u0435\u0440\u0441\u043a\u043e\u0433\u043e API.<\/p>\n<hr\/>\n<h4>\u0410\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0430<\/h4>\n<ul>\n<li>\n<p>\u0418\u0441\u0442\u043e\u0447\u043d\u0438\u043a \u0434\u0430\u043d\u043d\u044b\u0445: <a href=\"http:\/\/mygameodds.co\" rel=\"noopener noreferrer nofollow\">mygameodds.co<\/a><\/p>\n<\/li>\n<li>\n<p>\u0421\u0442\u0435\u043a:<\/p>\n<\/li>\n<li>\n<p>D3.js (\u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f)<\/p>\n<\/li>\n<li>\n<p>WebSocket (\u0441\u0442\u0440\u0438\u043c\u0438\u043d\u0433)<\/p>\n<\/li>\n<li>\n<p>TypeScript (\u0432\u0441\u044f \u043b\u043e\u0433\u0438\u043a\u0430)<\/p>\n<\/li>\n<li>\n<p>Vite + React (\u043e\u0431\u0432\u044f\u0437\u043a\u0430, \u0440\u0435\u043d\u0434\u0435\u0440)<\/p>\n<\/li>\n<\/ul>\n<hr\/>\n<h4>\u0420\u0430\u0431\u043e\u0442\u0430 \u0441 API<\/h4>\n<p>\u0414\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 \u043a <a href=\"http:\/\/mygameodds.co\" rel=\"noopener noreferrer nofollow\">mygameodds.co<\/a> \u043d\u0435 \u0431\u044b\u043b\u043e \u2014 \u0432\u0441\u0451 \u0441\u043e\u0431\u0438\u0440\u0430\u043b\u043e\u0441\u044c \u0447\u0435\u0440\u0435\u0437 \u0438\u043d\u0441\u043f\u0435\u043a\u0446\u0438\u044e \u0441\u0435\u0442\u0438 \u0438 reverse engineering.<\/p>\n<h4>\ud83d\udce1 \u041f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u043a WebSocket<\/h4>\n<pre><code>const socket = new WebSocket(\"wss:\/\/stream.mygameodds.co\/live\");  socket.onmessage = (event) =&gt; {   const data = JSON.parse(event.data);   handleIncomingEvent(data); }; <\/code><\/pre>\n<p>\u0421\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f \u043f\u0440\u0438\u0445\u043e\u0434\u044f\u0442 \u043f\u0430\u0447\u043a\u0430\u043c\u0438, \u0432 \u0444\u043e\u0440\u043c\u0430\u0442\u0435:<\/p>\n<pre><code>{   \"match_id\": 1234,   \"event\": \"odds_update\",   \"markets\": [     {       \"type\": \"match_winner\",       \"odds\": {         \"home\": 1.72,         \"draw\": 3.1,         \"away\": 4.5       }     }   ],   \"timestamp\": \"2025-08-03T14:22:01Z\" } <\/code><\/pre>\n<p>\u041f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u2014 \u043d\u0438\u043a\u0430\u043a\u043e\u0439 \u0441\u0442\u0430\u0431\u0438\u043b\u044c\u043d\u043e\u0441\u0442\u0438. \u0412 \u0434\u0440\u0443\u0433\u0438\u0445 \u043c\u0430\u0442\u0447\u0430\u0445:<\/p>\n<ul>\n<li>\n<p>odds = \u043c\u0430\u0441\u0441\u0438\u0432 \u0441 \u043a\u043b\u044e\u0447\u0430\u043c\u0438 &#171;name&#187; \/ &#171;value&#187;<\/p>\n<\/li>\n<li>\n<p>\u0412\u0440\u0435\u043c\u044f \u2014 \u0442\u043e\u043b\u044c\u043a\u043e updated_at, \u0438\u043d\u043e\u0433\u0434\u0430 \u0432 \u0444\u043e\u0440\u043c\u0430\u0442\u0435 Unix<\/p>\n<\/li>\n<li>\n<p>\u041d\u0430\u0437\u0432\u0430\u043d\u0438\u044f \u0438\u0441\u0445\u043e\u0434\u043e\u0432 (&#171;team1&#187;, &#171;x&#187;, &#171;team2&#187;)<\/p>\n<\/li>\n<\/ul>\n<hr\/>\n<h4>\u041d\u043e\u0440\u043c\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445<\/h4>\n<p>\u0427\u0442\u043e\u0431\u044b \u0443\u043d\u0438\u0444\u0438\u0446\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u0434\u043b\u044f \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438, \u043d\u0430\u043f\u0438\u0441\u0430\u043b \u043c\u043e\u0434\u0443\u043b\u044c normalizeOdds(data: RawEvent): NormalizedOdds[].<\/p>\n<h4>\ud83d\udd04 \u041f\u0440\u0438\u043c\u0435\u0440 \u043d\u043e\u0440\u043c\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440\u0430<\/h4>\n<pre><code>function normalizeOdds(event: RawEvent): NormalizedOdds[] {   const ts = new Date(event.timestamp || event.updated_at || Date.now()).toISOString();      return event.markets.map(m =&gt; {     const odds = m.odds || {};          const entries = Array.isArray(odds)       ? Object.fromEntries(odds.map((o: any) =&gt; [o.name.toLowerCase(), o.value]))       : odds;      return {       matchId: event.match_id,       type: m.type,       timestamp: ts,       home: entries.home || entries.team1 || null,       draw: entries.draw || entries.x || null,       away: entries.away || entries.team2 || null,     };   }); } <\/code><\/pre>\n<p>\u0412\u044b\u0445\u043e\u0434:<\/p>\n<pre><code>{   matchId: 1234,   type: 'match_winner',   timestamp: '2025-08-03T14:22:01Z',   home: 1.72,   draw: 3.1,   away: 4.5 } <\/code><\/pre>\n<hr\/>\n<h4>\u0425\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435 \u0438 \u043f\u043e\u0442\u043e\u043a \u0434\u0430\u043d\u043d\u044b\u0445<\/h4>\n<p>\u0421\u0434\u0435\u043b\u0430\u043b Map&lt;matchId, MatchState&gt; \u2014 \u0445\u0440\u0430\u043d\u0438\u043c \u0438\u0441\u0442\u043e\u0440\u0438\u044e \u043a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442\u043e\u0432 \u043f\u043e \u043c\u0430\u0442\u0447\u0430\u043c.<\/p>\n<p> \u041f\u0440\u0438 \u043a\u0430\u0436\u0434\u043e\u043c odds_update \u043f\u0443\u0448\u0438\u043c \u043d\u043e\u0432\u044b\u0435 \u0442\u043e\u0447\u043a\u0438 \u0432 \u043c\u0430\u0441\u0441\u0438\u0432 \u0438 \u0442\u0440\u0438\u0433\u0433\u0435\u0440\u0438\u043c requestAnimationFrame \u043d\u0430 \u0440\u0435\u0440\u0435\u043d\u0434\u0435\u0440.<\/p>\n<h4>\ud83e\udde0 \u041f\u0440\u043e\u0441\u0442\u0430\u044f \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430:<\/h4>\n<pre><code>interface MatchState {   history: {     timestamp: string     home: number | null     draw: number | null     away: number | null   }[] } <\/code><\/pre>\n<hr\/>\n<h4>\u0412\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043d\u0430 D3.js<\/h4>\n<h4>\u0417\u0430\u0434\u0430\u0447\u0438:<\/h4>\n<ul>\n<li>\n<p>\u041d\u0430\u0440\u0438\u0441\u043e\u0432\u0430\u0442\u044c \u0442\u0440\u0438 \u043b\u0438\u043d\u0438\u0438 (home, draw, away)<\/p>\n<\/li>\n<li>\n<p>\u041e\u0431\u043d\u043e\u0432\u043b\u044f\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u0432 real-time<\/p>\n<\/li>\n<li>\n<p>\u0414\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0437\u0443\u043c \u0438 pan (D3 Zoom Behavior)<\/p>\n<\/li>\n<\/ul>\n<h4>\ud83d\udcc8 \u041e\u0442\u0440\u0438\u0441\u043e\u0432\u043a\u0430 \u0433\u0440\u0430\u0444\u0438\u043a\u0430<\/h4>\n<pre><code>const svg = d3.select('#chart')   .attr('width', width)   .attr('height', height);  const x = d3.scaleTime().range([0, width]); const y = d3.scaleLinear().range([height, 0]);  const line = d3.line&lt;OddsPoint&gt;()   .x(d =&gt; x(new Date(d.timestamp)))   .y(d =&gt; y(d.home));  svg.append(\"path\")   .datum(match.history)   .attr(\"class\", \"line-home\")   .attr(\"d\", line); <\/code><\/pre>\n<p>\u041a\u0430\u0436\u0434\u0430\u044f \u043b\u0438\u043d\u0438\u044f \u0440\u0438\u0441\u0443\u0435\u0442\u0441\u044f \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e (\u0442\u0440\u0438 path \u043f\u043e \u043e\u0434\u043d\u043e\u043c\u0443 \u043d\u0430 \u0438\u0441\u0445\u043e\u0434).<\/p>\n<p>\u041e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 \u0434\u0435\u043b\u0430\u044e \u0447\u0435\u0440\u0435\u0437 join().attr(&#171;d&#187;, line) \u0432\u043d\u0443\u0442\u0440\u0438 RAF.<\/p>\n<hr\/>\n<h4>\u041f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u0441 \u0430\u0434\u0430\u043f\u0442\u0438\u0432\u043e\u043c<\/h4>\n<p>\u041d\u0430 \u0434\u0435\u0441\u043a\u0442\u043e\u043f\u0435 \u0432\u0441\u0451 \u043a\u0440\u0443\u0442\u043e. \u041d\u043e&#8230;<\/p>\n<ul>\n<li>\n<p>\u041d\u0430 \u043c\u043e\u0431\u0438\u043b\u043a\u0435 \u0437\u0443\u043c \u043b\u043e\u043c\u0430\u0435\u0442\u0441\u044f: \u043f\u0430\u043b\u044c\u0446\u044b \u0441\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u044e\u0442 \u043d\u0435\u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u043e, \u0441\u043e\u0431\u044b\u0442\u0438\u044f touchmove \u043a\u043e\u043d\u0444\u043b\u0438\u043a\u0442\u0443\u044e\u0442 \u0441 pan<\/p>\n<\/li>\n<li>\n<p>SVG \u043d\u0435 \u0432\u043b\u0435\u0437\u0430\u0435\u0442 \u043f\u043e \u0448\u0438\u0440\u0438\u043d\u0435, \u0433\u043e\u0440\u0438\u0437\u043e\u043d\u0442\u0430\u043b\u044c\u043d\u044b\u0439 \u0441\u043a\u0440\u043e\u043b\u043b \u043d\u0435 \u043f\u043e\u043c\u043e\u0433\u0430\u0435\u0442<\/p>\n<\/li>\n<li>\n<p>FPS \u043f\u0430\u0434\u0430\u0435\u0442 \u043f\u0440\u0438 200+ \u0442\u043e\u0447\u043a\u0430\u0445 \u043d\u0430 \u0433\u0440\u0430\u0444\u0438\u043a\u0435<\/p>\n<\/li>\n<\/ul>\n<p>\u0420\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u044e \u043f\u0435\u0440\u0435\u0445\u043e\u0434 \u043d\u0430:<\/p>\n<ul>\n<li>\n<p>Canvas \u2014 \u0440\u0430\u0434\u0438 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438<\/p>\n<\/li>\n<li>\n<p>WebGL (Pixi.js) \u2014 \u0435\u0441\u043b\u0438 \u0433\u0440\u0430\u0444\u0438\u043a\u043e\u0432 \u0431\u0443\u0434\u0435\u0442 \u043c\u043d\u043e\u0433\u043e<\/p>\n<\/li>\n<\/ul>\n<hr\/>\n<h4>\u0427\u0442\u043e \u043f\u043b\u0430\u043d\u0438\u0440\u0443\u044e \u0434\u0430\u043b\u044c\u0448\u0435<\/h4>\n<ul>\n<li>\n<p>\u041f\u0435\u0440\u0435\u0432\u0435\u0441\u0442\u0438 \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u043d\u0430 Canvas<\/p>\n<\/li>\n<li>\n<p>\u0421\u0434\u0435\u043b\u0430\u0442\u044c \u043e\u0442\u043b\u043e\u0436\u0435\u043d\u043d\u0443\u044e \u043e\u0442\u0440\u0438\u0441\u043e\u0432\u043a\u0443 (debounce + batch updates)<\/p>\n<\/li>\n<li>\n<p>\u0414\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0444\u0438\u043b\u044c\u0442\u0440\u044b \u043f\u043e \u043c\u0430\u0440\u043a\u0435\u0442\u0443<\/p>\n<\/li>\n<li>\n<p>\u041f\u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u0442\u044c SSR \u0434\u043b\u044f \u0441\u043d\u0438\u0436\u0435\u043d\u0438\u044f TTI (\u0435\u0441\u043b\u0438 \u0440\u0435\u043d\u0434\u0435\u0440\u0438\u0442\u044c \u0441\u0442\u0430\u0442\u0438\u043a\u0443)<\/p>\n<\/li>\n<\/ul>\n<hr\/>\n<h4>\u0418\u0442\u043e\u0433\u0438<\/h4>\n<p>\u0423\u0434\u0430\u043b\u043e\u0441\u044c:<\/p>\n<p>\u2705 \u041f\u0440\u043e\u0442\u044f\u043d\u0443\u0442\u044c live WebSocket-\u0434\u0430\u043d\u043d\u044b\u0435<\/p>\n<p> \u2705 \u041f\u0440\u0438\u0432\u0435\u0441\u0442\u0438 \u0445\u0430\u043e\u0442\u0438\u0447\u043d\u044b\u0435 odds \u043a \u0435\u0434\u0438\u043d\u043e\u043c\u0443 \u0444\u043e\u0440\u043c\u0430\u0442\u0443<\/p>\n<p> \u2705 \u0421\u043e\u0431\u0440\u0430\u0442\u044c \u0438\u043d\u0442\u0435\u0440\u0430\u043a\u0442\u0438\u0432\u043d\u044b\u0439 \u0433\u0440\u0430\u0444\u0438\u043a \u043d\u0430 D3.js<\/p>\n<p> \u2705 \u041f\u043e\u043a\u0430\u0437\u0430\u0442\u044c \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u0435 \u0434\u0432\u0438\u0436\u0435\u043d\u0438\u044f \u043a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442\u043e\u0432 \u043f\u043e \u043c\u0430\u0442\u0447\u0430\u043c<\/p>\n<p>\u041f\u0440\u043e\u0432\u0430\u043b\u0438\u043b\u043e\u0441\u044c:<\/p>\n<p>\u274c \u041c\u043e\u0431\u0438\u043b\u044c\u043d\u044b\u0439 UX (\u0437\u0443\u043c\/\u043f\u0435\u0440\u0435\u0445\u043e\u0434\u044b)<\/p>\n<p> \u274c \u041d\u0435\u0442 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0438 \u0441\u043b\u043e\u0436\u043d\u044b\u0445 \u043c\u0430\u0440\u043a\u0435\u0442\u043e\u0432 (\u0430\u0437\u0438\u0430\u0442\u0441\u043a\u0438\u0435 \u0444\u043e\u0440\u044b, \u0442\u043e\u0442\u0430\u043b\u044b)<\/p>\n<p> \u274c \u041f\u0435\u0440\u0444\u043e\u0440\u043c\u0430\u043d\u0441 \u043f\u0430\u0434\u0430\u0435\u0442 \u043d\u0430 \u0431\u043e\u043b\u044c\u0448\u0438\u0445 \u0432\u044b\u0431\u043e\u0440\u043a\u0430\u0445<\/p>\n<hr\/>\n<h4>P.S.<\/h4>\n<p>\u0415\u0441\u043b\u0438 \u0443 \u043a\u043e\u0433\u043e-\u0442\u043e \u0431\u044b\u043b \u043e\u043f\u044b\u0442 \u043f\u0435\u0440\u0435\u043d\u043e\u0441\u0430 \u043f\u043e\u0434\u043e\u0431\u043d\u044b\u0445 \u0433\u0440\u0430\u0444\u0438\u043a\u043e\u0432 \u0441 SVG \u043d\u0430 Canvas \u0438\u043b\u0438 WebGL \u2014 \u043f\u043e\u0434\u0435\u043b\u0438\u0442\u0435\u0441\u044c \u0441\u0441\u044b\u043b\u043a\u0430\u043c\u0438 \/ \u0434\u0435\u043c\u043a\u0430\u043c\u0438 \/ \u043f\u043e\u0434\u0445\u043e\u0434\u0430\u043c\u0438. \u0413\u043e\u0442\u043e\u0432 open-source-\u0438\u0442\u044c \u0447\u0430\u0441\u0442\u044c \u0440\u0435\u0448\u0435\u043d\u0438\u0439, \u0435\u0441\u043b\u0438 \u0431\u0443\u0434\u0435\u0442 \u0438\u043d\u0442\u0435\u0440\u0435\u0441.<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/933852\/\"> https:\/\/habr.com\/ru\/articles\/933852\/<\/a><br \/><\/br><\/br><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-469519","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/469519","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=469519"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/469519\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=469519"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=469519"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=469519"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}