qsharp-lang 1.0.33 → 1.1.0-dev
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.
- package/dist/browser.d.ts +2 -2
- package/dist/browser.js +1 -0
- package/dist/compiler/common.d.ts +1 -1
- package/dist/compiler/compiler.d.ts +1 -1
- package/dist/compiler/compiler.js +1 -2
- package/dist/debug-service/debug-service.d.ts +0 -1
- package/dist/debug-service/debug-service.js +2 -44
- package/dist/katas-content.generated.js +13 -13
- package/dist/language-service/language-service.d.ts +15 -18
- package/dist/language-service/language-service.js +17 -189
- package/dist/log.js +2 -3
- package/dist/main.d.ts +1 -0
- package/dist/main.js +1 -0
- package/dist/samples.generated.d.ts +8 -2
- package/dist/samples.generated.js +18 -0
- package/dist/utils.d.ts +24 -0
- package/dist/utils.js +148 -0
- package/lib/node/qsc_wasm.cjs +106 -113
- package/lib/node/qsc_wasm.d.cts +37 -37
- package/lib/node/qsc_wasm_bg.wasm +0 -0
- package/lib/web/qsc_wasm.d.ts +37 -37
- package/lib/web/qsc_wasm.js +101 -111
- package/lib/web/qsc_wasm_bg.wasm +0 -0
- package/package.json +1 -1
- package/ux/colormap.ts +51 -0
- package/ux/data.ts +65 -0
- package/ux/estimatesOverview.tsx +305 -0
- package/ux/estimatesPanel.tsx +94 -0
- package/ux/generate_report_code.py +243 -0
- package/ux/histogram.tsx +0 -1
- package/ux/index.ts +5 -2
- package/ux/output_data.md +537 -0
- package/ux/qsharp-ux.css +88 -8
- package/ux/reTable.tsx +7 -28
- package/ux/report.ts +591 -0
- package/ux/resultsTable.tsx +76 -67
- package/ux/scatterChart.tsx +300 -0
- package/ux/spaceChart.tsx +2 -2
- package/ux/tsconfig.json +0 -1
- package/dist/vsdiagnostic.d.ts +0 -19
- package/dist/vsdiagnostic.js +0 -127
package/ux/resultsTable.tsx
CHANGED
|
@@ -1,49 +1,35 @@
|
|
|
1
1
|
// Copyright (c) Microsoft Corporation.
|
|
2
2
|
// Licensed under the MIT License.
|
|
3
3
|
|
|
4
|
-
import { useRef, useState } from "preact/hooks";
|
|
5
|
-
import { type ReData } from "./reTable.js";
|
|
4
|
+
import { useRef, useState, useEffect } from "preact/hooks";
|
|
6
5
|
|
|
7
|
-
type CellValue = string | number | { value: string; sortBy: number };
|
|
6
|
+
export type CellValue = string | number | { value: string; sortBy: number };
|
|
7
|
+
export type Row = {
|
|
8
|
+
color: string;
|
|
9
|
+
cells: CellValue[];
|
|
10
|
+
};
|
|
8
11
|
|
|
9
12
|
// Note: column 0 is expected to be unique amongst all rows
|
|
10
13
|
export function ResultsTable(props: {
|
|
11
14
|
columnNames: string[];
|
|
12
|
-
|
|
15
|
+
rows: Row[];
|
|
13
16
|
initialColumns: number[];
|
|
14
|
-
ensureSelected: boolean;
|
|
15
|
-
onRowSelected(rowId: string): void;
|
|
16
17
|
onRowDeleted(rowId: string): void;
|
|
18
|
+
selectedRow: string | null;
|
|
19
|
+
onRowSelected(rowId: string): void;
|
|
17
20
|
}) {
|
|
18
21
|
const [showColumns, setShowColumns] = useState(props.initialColumns);
|
|
19
22
|
const [sortColumn, setSortColumn] = useState<{
|
|
20
23
|
columnId: number;
|
|
21
24
|
ascending: boolean;
|
|
22
25
|
} | null>(null);
|
|
23
|
-
|
|
26
|
+
|
|
24
27
|
const [showColumnMenu, setShowColumnMenu] = useState(false);
|
|
25
28
|
const [showRowMenu, setShowRowMenu] = useState("");
|
|
26
29
|
|
|
27
|
-
const rows = props.data.map(ReDataToRow);
|
|
28
|
-
|
|
29
|
-
// Find the first row that is new in the current sort order
|
|
30
|
-
const newest = getSortedRows(rows).find(
|
|
31
|
-
(row) => (row[row.length - 1] as string) === "New",
|
|
32
|
-
);
|
|
33
|
-
|
|
34
|
-
// Select the first of the newest rows, otherwise preserve the existing selection
|
|
35
|
-
if (newest && props.ensureSelected) {
|
|
36
|
-
const rowId = newest[0].toString();
|
|
37
|
-
setSelectedRow(rowId);
|
|
38
|
-
props.onRowSelected(rowId);
|
|
39
|
-
} else if (!selectedRow && props.ensureSelected && rows.length > 0) {
|
|
40
|
-
const rowId = rows[0][0].toString();
|
|
41
|
-
setSelectedRow(rowId);
|
|
42
|
-
props.onRowSelected(rowId);
|
|
43
|
-
}
|
|
44
|
-
|
|
45
30
|
// Use to track the column being dragged
|
|
46
31
|
const draggingCol = useRef("");
|
|
32
|
+
const columnMenu = useRef<HTMLDivElement>(null);
|
|
47
33
|
|
|
48
34
|
/*
|
|
49
35
|
Note: Drag and drop events can occur faster than preact reconciles state.
|
|
@@ -79,6 +65,10 @@ export function ResultsTable(props: {
|
|
|
79
65
|
}
|
|
80
66
|
}
|
|
81
67
|
|
|
68
|
+
function onRowSelected(rowId: string) {
|
|
69
|
+
props.onRowSelected(rowId);
|
|
70
|
+
}
|
|
71
|
+
|
|
82
72
|
function onDragOver(ev: DragEvent) {
|
|
83
73
|
if (!(ev.target instanceof HTMLElement)) return;
|
|
84
74
|
const thisColId = ev.target.closest("th")?.dataset["colid"];
|
|
@@ -156,7 +146,7 @@ export function ResultsTable(props: {
|
|
|
156
146
|
}
|
|
157
147
|
}
|
|
158
148
|
|
|
159
|
-
function getSortedRows(rows:
|
|
149
|
+
function getSortedRows(rows: Row[]) {
|
|
160
150
|
if (!sortColumn) return rows;
|
|
161
151
|
|
|
162
152
|
const colIdx = sortColumn.columnId;
|
|
@@ -164,8 +154,8 @@ export function ResultsTable(props: {
|
|
|
164
154
|
|
|
165
155
|
const sortedRows = [...rows];
|
|
166
156
|
sortedRows.sort((a, b) => {
|
|
167
|
-
const aVal = a[colIdx];
|
|
168
|
-
const bVal = b[colIdx];
|
|
157
|
+
const aVal = a.cells[colIdx];
|
|
158
|
+
const bVal = b.cells[colIdx];
|
|
169
159
|
if (typeof aVal === "string" && typeof bVal === "string") {
|
|
170
160
|
return ascending ? aVal.localeCompare(bVal) : bVal.localeCompare(aVal);
|
|
171
161
|
} else if (typeof aVal === "number" && typeof bVal === "number") {
|
|
@@ -192,12 +182,9 @@ export function ResultsTable(props: {
|
|
|
192
182
|
}
|
|
193
183
|
}
|
|
194
184
|
|
|
195
|
-
function
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
const newSelectedRow = selectedRow === rowId ? "" : rowId;
|
|
199
|
-
setSelectedRow(newSelectedRow);
|
|
200
|
-
props.onRowSelected(newSelectedRow);
|
|
185
|
+
function onRowClicked(rowId: string) {
|
|
186
|
+
const newSelectedRow = props.selectedRow === rowId ? "" : rowId;
|
|
187
|
+
onRowSelected(newSelectedRow);
|
|
201
188
|
}
|
|
202
189
|
|
|
203
190
|
function onClickRowMenu(ev: MouseEvent, rowid: string) {
|
|
@@ -246,19 +233,60 @@ export function ResultsTable(props: {
|
|
|
246
233
|
e.stopPropagation();
|
|
247
234
|
// Clear out any menus or selections for the row if needed
|
|
248
235
|
setShowRowMenu("");
|
|
249
|
-
if (selectedRow === rowId) {
|
|
250
|
-
|
|
251
|
-
props.onRowSelected("");
|
|
236
|
+
if (props.selectedRow === rowId) {
|
|
237
|
+
onRowSelected("");
|
|
252
238
|
}
|
|
253
239
|
props.onRowDeleted(rowId);
|
|
254
240
|
}
|
|
255
241
|
|
|
242
|
+
function onKeyDown(ev: KeyboardEvent) {
|
|
243
|
+
if (!props.selectedRow) return;
|
|
244
|
+
const sortedRowNames = getSortedRows(props.rows).map((row) =>
|
|
245
|
+
row.cells[0].toString(),
|
|
246
|
+
);
|
|
247
|
+
const currIndex = sortedRowNames.indexOf(props.selectedRow);
|
|
248
|
+
|
|
249
|
+
switch (ev.code) {
|
|
250
|
+
case "ArrowDown":
|
|
251
|
+
if (currIndex < sortedRowNames.length - 1) {
|
|
252
|
+
ev.preventDefault();
|
|
253
|
+
props.onRowSelected(sortedRowNames[currIndex + 1]);
|
|
254
|
+
}
|
|
255
|
+
break;
|
|
256
|
+
case "ArrowUp":
|
|
257
|
+
if (currIndex > 0) {
|
|
258
|
+
ev.preventDefault();
|
|
259
|
+
props.onRowSelected(sortedRowNames[currIndex - 1]);
|
|
260
|
+
}
|
|
261
|
+
break;
|
|
262
|
+
default:
|
|
263
|
+
// Not of interest
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
useEffect(() => {
|
|
268
|
+
// Post rendering, if the column menu is displayed, then ensure it
|
|
269
|
+
// has focus so that clicking anywhere outside of it caused the blur
|
|
270
|
+
// event that closes it.
|
|
271
|
+
if (showColumnMenu && columnMenu.current) {
|
|
272
|
+
columnMenu.current.focus();
|
|
273
|
+
}
|
|
274
|
+
});
|
|
275
|
+
|
|
256
276
|
return (
|
|
257
|
-
<table
|
|
277
|
+
<table
|
|
278
|
+
class="qs-resultsTable-sortedTable"
|
|
279
|
+
tabIndex={0}
|
|
280
|
+
onKeyDown={onKeyDown}
|
|
281
|
+
>
|
|
258
282
|
<thead>
|
|
259
283
|
<tr>
|
|
260
284
|
<th>
|
|
261
|
-
<div
|
|
285
|
+
<div
|
|
286
|
+
style="position: relative"
|
|
287
|
+
tabIndex={0}
|
|
288
|
+
onBlur={() => setShowColumnMenu(false)}
|
|
289
|
+
>
|
|
262
290
|
<svg
|
|
263
291
|
width="16"
|
|
264
292
|
height="16"
|
|
@@ -283,6 +311,7 @@ export function ResultsTable(props: {
|
|
|
283
311
|
/>
|
|
284
312
|
</svg>
|
|
285
313
|
<div
|
|
314
|
+
ref={columnMenu}
|
|
286
315
|
class={
|
|
287
316
|
showColumnMenu
|
|
288
317
|
? "qs-resultsTable-columnMenu qs-resultsTable-showColumnMenu"
|
|
@@ -344,14 +373,14 @@ export function ResultsTable(props: {
|
|
|
344
373
|
</tr>
|
|
345
374
|
</thead>
|
|
346
375
|
<tbody>
|
|
347
|
-
{getSortedRows(rows).map((row) => {
|
|
348
|
-
const rowId = row[0].toString();
|
|
376
|
+
{getSortedRows(props.rows).map((row) => {
|
|
377
|
+
const rowId = row.cells[0].toString();
|
|
349
378
|
return (
|
|
350
379
|
<tr
|
|
351
|
-
onClick={() =>
|
|
380
|
+
onClick={() => onRowClicked(rowId)}
|
|
352
381
|
data-rowid={rowId}
|
|
353
382
|
class={
|
|
354
|
-
rowId === selectedRow
|
|
383
|
+
rowId === props.selectedRow
|
|
355
384
|
? "qs-resultsTable-sortedTableSelectedRow"
|
|
356
385
|
: undefined
|
|
357
386
|
}
|
|
@@ -364,7 +393,7 @@ export function ResultsTable(props: {
|
|
|
364
393
|
<svg width="16" height="16" style="position: relative;">
|
|
365
394
|
<path
|
|
366
395
|
stroke-width="1.5"
|
|
367
|
-
stroke=
|
|
396
|
+
stroke={row.color}
|
|
368
397
|
stroke-linecap="round"
|
|
369
398
|
d="M4,5 h8 M4,8 h8 M4,11 h8"
|
|
370
399
|
/>
|
|
@@ -386,7 +415,9 @@ export function ResultsTable(props: {
|
|
|
386
415
|
</td>
|
|
387
416
|
{showColumns.map((idx) => {
|
|
388
417
|
return (
|
|
389
|
-
<td data-colid={idx.toString()}>
|
|
418
|
+
<td data-colid={idx.toString()}>
|
|
419
|
+
{getCellStr(row.cells[idx])}
|
|
420
|
+
</td>
|
|
390
421
|
);
|
|
391
422
|
})}
|
|
392
423
|
</tr>
|
|
@@ -396,25 +427,3 @@ export function ResultsTable(props: {
|
|
|
396
427
|
</table>
|
|
397
428
|
);
|
|
398
429
|
}
|
|
399
|
-
|
|
400
|
-
function ReDataToRow(data: ReData): CellValue[] {
|
|
401
|
-
return [
|
|
402
|
-
data.jobParams.runName,
|
|
403
|
-
data.jobParams.qubitParams.name,
|
|
404
|
-
data.jobParams.qecScheme.name,
|
|
405
|
-
data.jobParams.errorBudget,
|
|
406
|
-
data.physicalCounts.breakdown.algorithmicLogicalQubits,
|
|
407
|
-
data.physicalCounts.breakdown.algorithmicLogicalDepth,
|
|
408
|
-
data.logicalQubit.codeDistance,
|
|
409
|
-
data.physicalCounts.breakdown.numTstates,
|
|
410
|
-
data.physicalCounts.breakdown.numTfactories,
|
|
411
|
-
data.physicalCountsFormatted.physicalQubitsForTfactoriesPercentage,
|
|
412
|
-
{
|
|
413
|
-
value: data.physicalCountsFormatted.runtime,
|
|
414
|
-
sortBy: data.physicalCounts.runtime,
|
|
415
|
-
},
|
|
416
|
-
data.physicalCounts.rqops,
|
|
417
|
-
data.physicalCounts.physicalQubits,
|
|
418
|
-
data.new ? "New" : "Cached",
|
|
419
|
-
];
|
|
420
|
-
}
|
|
@@ -0,0 +1,300 @@
|
|
|
1
|
+
// Copyright (c) Microsoft Corporation.
|
|
2
|
+
// Licensed under the MIT License.
|
|
3
|
+
|
|
4
|
+
import { useRef, useEffect } from "preact/hooks";
|
|
5
|
+
import * as utils from "../src/utils.js";
|
|
6
|
+
|
|
7
|
+
export type ScatterSeries = {
|
|
8
|
+
color: string;
|
|
9
|
+
items: PlotItem[];
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export type PlotItem = {
|
|
13
|
+
x: number;
|
|
14
|
+
y: number;
|
|
15
|
+
label: string;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export type Axis = {
|
|
19
|
+
isTime: boolean;
|
|
20
|
+
label: string;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
type Range = {
|
|
24
|
+
min: number;
|
|
25
|
+
max: number;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export function ScatterChart(props: {
|
|
29
|
+
data: ScatterSeries[];
|
|
30
|
+
xAxis: Axis;
|
|
31
|
+
yAxis: Axis;
|
|
32
|
+
onPointSelected(seriesIndex: number, pointIndex: number): void;
|
|
33
|
+
selectedPoint?: [number, number];
|
|
34
|
+
}) {
|
|
35
|
+
const selectedTooltipDiv = useRef<HTMLDivElement>(null);
|
|
36
|
+
|
|
37
|
+
const { rangeX, rangeY } = utils.getRanges(props.data, 2 /* coefficient */);
|
|
38
|
+
|
|
39
|
+
function createAxisTicks(range: Range, isTime: boolean): utils.Tick[] {
|
|
40
|
+
return isTime
|
|
41
|
+
? utils.CreateTimeTicks(range.min, range.max)
|
|
42
|
+
: utils.CreateIntegerTicks(range.min, range.max);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const xTicks = createAxisTicks(rangeX, props.xAxis.isTime);
|
|
46
|
+
const yTicks = createAxisTicks(rangeY, props.yAxis.isTime);
|
|
47
|
+
|
|
48
|
+
function coordinateToLogarithmic(value: number, range: Range): number {
|
|
49
|
+
return (
|
|
50
|
+
(Math.log(value) - Math.log(range.min)) /
|
|
51
|
+
(Math.log(range.max) - Math.log(range.min))
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function toLogX(val: number): number {
|
|
56
|
+
return coordinateToLogarithmic(val, rangeX) * plotAreaWidth;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function toLogY(val: number): number {
|
|
60
|
+
return -coordinateToLogarithmic(val, rangeY) * plotAreaHeight;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const yAxisTitleWidth = 20;
|
|
64
|
+
const yAxisTickCaptionMaxWidth = 100;
|
|
65
|
+
const axisTickLength = 5;
|
|
66
|
+
const axisLineWidth = 1;
|
|
67
|
+
const xLeftMargin =
|
|
68
|
+
yAxisTitleWidth + yAxisTickCaptionMaxWidth + axisTickLength + axisLineWidth;
|
|
69
|
+
const xRightMargin = 160; // to show tooltips on the right hand side. If we can move tooltips dynamically, we can get rid of this.
|
|
70
|
+
|
|
71
|
+
const axisTitleHeight = 20;
|
|
72
|
+
const xAxisTickCaptionMaxHeight = 16;
|
|
73
|
+
const yMargin =
|
|
74
|
+
axisTitleHeight +
|
|
75
|
+
xAxisTickCaptionMaxHeight +
|
|
76
|
+
axisTickLength +
|
|
77
|
+
axisLineWidth;
|
|
78
|
+
|
|
79
|
+
const svgWidth = 960;
|
|
80
|
+
const svgViewBoxWidthPadding = 50;
|
|
81
|
+
const svgHeight = 480;
|
|
82
|
+
const svgViewBoxHeightPadding = 10;
|
|
83
|
+
const svgXMin = -xLeftMargin;
|
|
84
|
+
|
|
85
|
+
const plotAreaWidth = svgWidth - xLeftMargin - xRightMargin;
|
|
86
|
+
const plotAreaHeight = svgHeight - yMargin;
|
|
87
|
+
|
|
88
|
+
const viewBox = `${svgXMin} ${-plotAreaHeight - svgViewBoxHeightPadding} ${
|
|
89
|
+
svgWidth + svgViewBoxWidthPadding
|
|
90
|
+
} ${svgHeight + svgViewBoxHeightPadding}`;
|
|
91
|
+
|
|
92
|
+
const yAxisTextPaddingFromTicks = 5;
|
|
93
|
+
const yAxisTextYPadding = 4;
|
|
94
|
+
|
|
95
|
+
function renderTooltip(
|
|
96
|
+
topDiv: HTMLDivElement,
|
|
97
|
+
point: SVGCircleElement,
|
|
98
|
+
tooltip: HTMLDivElement,
|
|
99
|
+
) {
|
|
100
|
+
const label = point.getAttribute("data-label");
|
|
101
|
+
tooltip.textContent = label;
|
|
102
|
+
const halfWidth = tooltip.offsetWidth / 2;
|
|
103
|
+
const pointRect = point.getBoundingClientRect();
|
|
104
|
+
const centerY = (pointRect.top + pointRect.bottom) / 2;
|
|
105
|
+
const centerX = (pointRect.left + pointRect.right) / 2;
|
|
106
|
+
const divRect = topDiv.getBoundingClientRect();
|
|
107
|
+
tooltip.style.left = `${centerX - divRect.left - halfWidth}px`;
|
|
108
|
+
tooltip.style.top = `${centerY - divRect.top + 12}px`;
|
|
109
|
+
tooltip.style.visibility = "visible";
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
function onPointMouseEvent(ev: MouseEvent, eventType: string) {
|
|
113
|
+
// Ensure we have a point as the target
|
|
114
|
+
if (!(ev.target instanceof SVGCircleElement)) return;
|
|
115
|
+
const target = ev.target as SVGCircleElement;
|
|
116
|
+
if (!target.classList.contains("qs-scatterChart-point")) return;
|
|
117
|
+
|
|
118
|
+
// Get the div enclosing the chart, and the popup child of it.
|
|
119
|
+
const topDiv = target.closest("div") as HTMLDivElement;
|
|
120
|
+
const popup = topDiv.querySelector(
|
|
121
|
+
".qs-scatterChart-tooltip",
|
|
122
|
+
) as HTMLDivElement;
|
|
123
|
+
|
|
124
|
+
switch (eventType) {
|
|
125
|
+
case "over":
|
|
126
|
+
{
|
|
127
|
+
renderTooltip(topDiv, target, popup);
|
|
128
|
+
}
|
|
129
|
+
break;
|
|
130
|
+
case "out":
|
|
131
|
+
popup.style.visibility = "hidden";
|
|
132
|
+
break;
|
|
133
|
+
case "click":
|
|
134
|
+
{
|
|
135
|
+
if (target.classList.contains("qs-scatterChart-point-selected")) {
|
|
136
|
+
// Clicked on the already selected point, so delete the point/row
|
|
137
|
+
props.onPointSelected(-1, 0);
|
|
138
|
+
} else {
|
|
139
|
+
const index = JSON.parse(target.getAttribute("data-index")!);
|
|
140
|
+
props.onPointSelected(index[0], index[1]);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
break;
|
|
144
|
+
default:
|
|
145
|
+
console.error("Unknown event type: ", eventType);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
function getSelectedPointData() {
|
|
150
|
+
if (!props.selectedPoint) return null;
|
|
151
|
+
const series = props.data[props.selectedPoint[0]];
|
|
152
|
+
const item = series.items[props.selectedPoint[1]];
|
|
153
|
+
return { ...item, color: series.color };
|
|
154
|
+
}
|
|
155
|
+
const selectedPoint = getSelectedPointData();
|
|
156
|
+
|
|
157
|
+
// Need to render first to get the element layout to position the tooltip
|
|
158
|
+
useEffect(() => {
|
|
159
|
+
if (!selectedTooltipDiv.current) return;
|
|
160
|
+
if (!props.selectedPoint) {
|
|
161
|
+
selectedTooltipDiv.current.style.visibility = "hidden";
|
|
162
|
+
} else {
|
|
163
|
+
// Locate the selected point and put the tooltip under it
|
|
164
|
+
const topDiv = selectedTooltipDiv.current.parentElement as HTMLDivElement;
|
|
165
|
+
const selectedPoint = topDiv?.querySelector(
|
|
166
|
+
".qs-scatterChart-point-selected",
|
|
167
|
+
) as SVGCircleElement;
|
|
168
|
+
if (!selectedPoint) return;
|
|
169
|
+
renderTooltip(topDiv, selectedPoint, selectedTooltipDiv.current);
|
|
170
|
+
}
|
|
171
|
+
});
|
|
172
|
+
|
|
173
|
+
// The mouse events (over, out, and click) bubble, so put the hanlders on the
|
|
174
|
+
// SVG element and check the target element in the handler.
|
|
175
|
+
return (
|
|
176
|
+
<div style="position: relative">
|
|
177
|
+
<svg
|
|
178
|
+
style="margin-top: 12px"
|
|
179
|
+
viewBox={viewBox}
|
|
180
|
+
width={svgWidth}
|
|
181
|
+
height={svgHeight}
|
|
182
|
+
onMouseOver={(ev) => onPointMouseEvent(ev, "over")}
|
|
183
|
+
onMouseOut={(ev) => onPointMouseEvent(ev, "out")}
|
|
184
|
+
onClick={(ev) => onPointMouseEvent(ev, "click")}
|
|
185
|
+
>
|
|
186
|
+
<line
|
|
187
|
+
class="qs-scatterChart-axis"
|
|
188
|
+
x1="0"
|
|
189
|
+
y1="0"
|
|
190
|
+
x2={plotAreaWidth}
|
|
191
|
+
y2="0"
|
|
192
|
+
/>
|
|
193
|
+
|
|
194
|
+
{xTicks.map((tick) => {
|
|
195
|
+
return (
|
|
196
|
+
<>
|
|
197
|
+
<line
|
|
198
|
+
y1="1"
|
|
199
|
+
y2={axisTickLength}
|
|
200
|
+
x1={toLogX(tick.value)}
|
|
201
|
+
x2={toLogX(tick.value)}
|
|
202
|
+
class="qs-scatterChart-tick-line"
|
|
203
|
+
/>
|
|
204
|
+
<text
|
|
205
|
+
y={axisTickLength + xAxisTickCaptionMaxHeight}
|
|
206
|
+
x={toLogX(tick.value)}
|
|
207
|
+
class="qs-scatterChart-x-tick-text"
|
|
208
|
+
>
|
|
209
|
+
{tick.label}
|
|
210
|
+
</text>
|
|
211
|
+
</>
|
|
212
|
+
);
|
|
213
|
+
})}
|
|
214
|
+
|
|
215
|
+
<line
|
|
216
|
+
class="qs-scatterChart-axis"
|
|
217
|
+
x1="0"
|
|
218
|
+
y1="0"
|
|
219
|
+
x2="0"
|
|
220
|
+
y2={-svgHeight}
|
|
221
|
+
/>
|
|
222
|
+
|
|
223
|
+
{yTicks.map((tick) => {
|
|
224
|
+
return (
|
|
225
|
+
<>
|
|
226
|
+
<line
|
|
227
|
+
x1="0"
|
|
228
|
+
x2={-axisTickLength}
|
|
229
|
+
y1={toLogY(tick.value)}
|
|
230
|
+
y2={toLogY(tick.value)}
|
|
231
|
+
class="qs-scatterChart-tick-line"
|
|
232
|
+
/>
|
|
233
|
+
<text
|
|
234
|
+
x={-axisTickLength - yAxisTextPaddingFromTicks}
|
|
235
|
+
y={toLogY(tick.value) + yAxisTextYPadding}
|
|
236
|
+
class="qs-scatterChart-y-tick-text"
|
|
237
|
+
>
|
|
238
|
+
{tick.label}
|
|
239
|
+
</text>
|
|
240
|
+
</>
|
|
241
|
+
);
|
|
242
|
+
})}
|
|
243
|
+
|
|
244
|
+
<text
|
|
245
|
+
x={plotAreaWidth / 2}
|
|
246
|
+
y={yMargin}
|
|
247
|
+
class="qs-scatterChart-x-axisTitle"
|
|
248
|
+
>
|
|
249
|
+
{props.xAxis.label} (logarithmic)
|
|
250
|
+
</text>
|
|
251
|
+
|
|
252
|
+
<text
|
|
253
|
+
x={xLeftMargin - axisTitleHeight}
|
|
254
|
+
y={plotAreaHeight / 2}
|
|
255
|
+
class="qs-scatterChart-y-axisTitle"
|
|
256
|
+
>
|
|
257
|
+
{props.yAxis.label} (logarithmic)
|
|
258
|
+
</text>
|
|
259
|
+
|
|
260
|
+
<text
|
|
261
|
+
class="qs-scatterChart-watermark"
|
|
262
|
+
x={xLeftMargin - axisTitleHeight}
|
|
263
|
+
y={-svgHeight + yMargin}
|
|
264
|
+
>
|
|
265
|
+
Created with Azure Quantum Resource Estimator
|
|
266
|
+
</text>
|
|
267
|
+
<g>
|
|
268
|
+
{props.data.map((series, seriesIdx) => {
|
|
269
|
+
return series.items.map((plot, plotIdx) => {
|
|
270
|
+
return (
|
|
271
|
+
<circle
|
|
272
|
+
data-index={JSON.stringify([seriesIdx, plotIdx])}
|
|
273
|
+
data-label={plot.label}
|
|
274
|
+
class="qs-scatterChart-point qs-scatterChart-hover"
|
|
275
|
+
cx={toLogX(plot.x)}
|
|
276
|
+
cy={toLogY(plot.y)}
|
|
277
|
+
stroke={series.color}
|
|
278
|
+
/>
|
|
279
|
+
);
|
|
280
|
+
});
|
|
281
|
+
})}
|
|
282
|
+
</g>
|
|
283
|
+
{
|
|
284
|
+
// Render the selected point last, so it's always on top of the others
|
|
285
|
+
selectedPoint ? (
|
|
286
|
+
<circle
|
|
287
|
+
class="qs-scatterChart-point qs-scatterChart-point-selected"
|
|
288
|
+
data-label={selectedPoint.label}
|
|
289
|
+
cx={toLogX(selectedPoint.x)}
|
|
290
|
+
cy={toLogY(selectedPoint.y)}
|
|
291
|
+
stroke={selectedPoint.color}
|
|
292
|
+
/>
|
|
293
|
+
) : null
|
|
294
|
+
}
|
|
295
|
+
</svg>
|
|
296
|
+
<div class="qs-scatterChart-selectedInfo" ref={selectedTooltipDiv}></div>
|
|
297
|
+
<div class="qs-scatterChart-tooltip"></div>
|
|
298
|
+
</div>
|
|
299
|
+
);
|
|
300
|
+
}
|
package/ux/spaceChart.tsx
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// Copyright (c) Microsoft Corporation.
|
|
2
2
|
// Licensed under the MIT License.
|
|
3
3
|
|
|
4
|
-
import {
|
|
4
|
+
import { SingleEstimateResult } from "./data.js";
|
|
5
5
|
|
|
6
6
|
function getPieSegment(
|
|
7
7
|
x: number,
|
|
@@ -26,7 +26,7 @@ function getPieSegment(
|
|
|
26
26
|
return d;
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
export function SpaceChart(props: { estimatesData:
|
|
29
|
+
export function SpaceChart(props: { estimatesData: SingleEstimateResult }) {
|
|
30
30
|
const breakdown = props.estimatesData.physicalCounts.breakdown;
|
|
31
31
|
|
|
32
32
|
// The values to be shown on the pie chart
|
package/ux/tsconfig.json
CHANGED
package/dist/vsdiagnostic.d.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { type VSDiagnostic } from "../lib/web/qsc_wasm.js";
|
|
2
|
-
export { type VSDiagnostic } from "../lib/web/qsc_wasm.js";
|
|
3
|
-
/**
|
|
4
|
-
* @param positions - An array of utf-8 code unit indexes to map to utf-16 code unit indexes
|
|
5
|
-
* @param source - The source code to do the mapping on
|
|
6
|
-
* @returns An object where the keys are the utf-8 index and the values are the utf-16 index
|
|
7
|
-
*/
|
|
8
|
-
export declare function mapUtf16UnitsToUtf8Units(positions: Array<number>, source: string): {
|
|
9
|
-
[index: number]: number;
|
|
10
|
-
};
|
|
11
|
-
/**
|
|
12
|
-
* @param positions - An array of utf-8 code unit indexes to map to utf-16 code unit indexes
|
|
13
|
-
* @param source - The source code to do the mapping on
|
|
14
|
-
* @returns An object where the keys are the utf-8 index and the values are the utf-16 index
|
|
15
|
-
*/
|
|
16
|
-
export declare function mapUtf8UnitsToUtf16Units(positions: Array<number>, source: string): {
|
|
17
|
-
[index: number]: number;
|
|
18
|
-
};
|
|
19
|
-
export declare function mapDiagnostics(diags: VSDiagnostic[], code: string): VSDiagnostic[];
|