(url: string | Blob | URL | File, callback: () => void)
| 1900 | } |
| 1901 | |
| 1902 | load(url: string | Blob | URL | File, callback: () => void) { |
| 1903 | const that = this |
| 1904 | |
| 1905 | // from file |
| 1906 | if (url instanceof Blob || url instanceof File) { |
| 1907 | const reader = new FileReader() |
| 1908 | reader.addEventListener("load", function (event) { |
| 1909 | const result = stringOrEmpty(event.target?.result) |
| 1910 | const data = JSON.parse(result) |
| 1911 | that.configure(data) |
| 1912 | callback?.() |
| 1913 | }) |
| 1914 | |
| 1915 | reader.readAsText(url) |
| 1916 | return |
| 1917 | } |
| 1918 | |
| 1919 | // is a string, then an URL |
| 1920 | const req = new XMLHttpRequest() |
| 1921 | req.open("GET", url, true) |
| 1922 | req.send(null) |
| 1923 | req.addEventListener("load", function () { |
| 1924 | if (req.status !== 200) { |
| 1925 | console.error("Error loading graph:", req.status, req.response) |
| 1926 | return |
| 1927 | } |
| 1928 | const data = JSON.parse(req.response) |
| 1929 | that.configure(data) |
| 1930 | callback?.() |
| 1931 | }) |
| 1932 | req.addEventListener("error", (err) => { |
| 1933 | console.error("Error loading graph:", err) |
| 1934 | }) |
| 1935 | } |
| 1936 | } |
nothing calls this directly
no test coverage detected