@inflexa-ai/harness 0.42.2 → 0.43.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.
- package/README.md +2 -2
- package/dist/agents/sandbox/shared.d.ts +1 -6
- package/dist/agents/sandbox/shared.js +0 -15
- package/dist/app/chat-turn.js +13 -1
- package/dist/config/environment-stores.d.ts +4 -2
- package/dist/contracts/chat-events.d.ts +9 -1
- package/dist/contracts/chat-frame.d.ts +3 -3
- package/dist/contracts/chat-frame.js +8 -3
- package/dist/contracts/chat-parts.d.ts +4 -1
- package/dist/contracts/data-profile.d.ts +4 -6
- package/dist/contracts/index.d.ts +1 -1
- package/dist/contracts/report-blocks.d.ts +1364 -75
- package/dist/contracts/report-blocks.js +221 -29
- package/dist/contracts/report-reference.js +1 -1
- package/dist/contracts/schemas/chat-events.d.ts +13 -0
- package/dist/contracts/schemas/chat-events.js +5 -0
- package/dist/contracts/schemas/chat-parts.d.ts +2 -2
- package/dist/contracts/schemas/index.d.ts +1 -1
- package/dist/contracts/schemas/index.js +1 -1
- package/dist/execution/input-signature.d.ts +7 -13
- package/dist/execution/input-signature.js +0 -0
- package/dist/execution/run-canceler.d.ts +3 -2
- package/dist/execution/run-canceler.js +3 -2
- package/dist/execution/run-event-stream.d.ts +16 -2
- package/dist/execution/run-event-stream.js +54 -3
- package/dist/index.d.ts +1 -8
- package/dist/index.js +5 -16
- package/dist/input-scan/enrich.d.ts +0 -2
- package/dist/input-scan/enrich.js +0 -1
- package/dist/lib/metrics.js +6 -7
- package/dist/lib/otel-spans.d.ts +4 -9
- package/dist/lib/otel-spans.js +3 -8
- package/dist/loop/run-agent.d.ts +4 -2
- package/dist/loop/run-agent.js +38 -23
- package/dist/memory/thread-history.d.ts +1 -1
- package/dist/prompts/report-session.d.ts +1 -1
- package/dist/prompts/report-session.js +17 -0
- package/dist/provenance/exec-frame.d.ts +1 -1
- package/dist/report-model/authoring-grammar.d.ts +416 -17
- package/dist/report-model/authoring-grammar.js +25 -4
- package/dist/report-model/block-walk.d.ts +20 -4
- package/dist/report-model/block-walk.js +64 -7
- package/dist/report-model/draft-finish.d.ts +6 -2
- package/dist/report-model/draft-finish.js +6 -1
- package/dist/report-model/production-resolver.d.ts +8 -0
- package/dist/report-model/production-resolver.js +1 -1
- package/dist/report-model/validate.d.ts +20 -10
- package/dist/report-model/validate.js +29 -13
- package/dist/report-render/chart-export.d.ts +52 -0
- package/dist/report-render/chart-export.js +192 -0
- package/dist/report-render/chart-presets.d.ts +46 -47
- package/dist/report-render/chart-presets.js +31 -101
- package/dist/report-render/chart-renderers.d.ts +163 -0
- package/dist/report-render/chart-renderers.js +1055 -0
- package/dist/report-render/chart-toolbox.d.ts +124 -0
- package/dist/report-render/chart-toolbox.js +595 -0
- package/dist/report-render/chart.d.ts +60 -27
- package/dist/report-render/chart.js +2323 -524
- package/dist/report-render/design.d.ts +476 -16
- package/dist/report-render/design.js +390 -56
- package/dist/report-render/figures/common.d.ts +321 -0
- package/dist/report-render/figures/common.js +759 -0
- package/dist/report-render/figures/dendrogram.d.ts +36 -0
- package/dist/report-render/figures/dendrogram.js +130 -0
- package/dist/report-render/figures/dense.d.ts +111 -0
- package/dist/report-render/figures/dense.js +204 -0
- package/dist/report-render/figures/dotplot.d.ts +28 -0
- package/dist/report-render/figures/dotplot.js +234 -0
- package/dist/report-render/figures/embedding.d.ts +43 -0
- package/dist/report-render/figures/embedding.js +360 -0
- package/dist/report-render/figures/equal-units.d.ts +101 -0
- package/dist/report-render/figures/equal-units.js +215 -0
- package/dist/report-render/figures/forest.d.ts +20 -0
- package/dist/report-render/figures/forest.js +398 -0
- package/dist/report-render/figures/gsea.d.ts +30 -0
- package/dist/report-render/figures/gsea.js +391 -0
- package/dist/report-render/figures/heatmap.d.ts +40 -0
- package/dist/report-render/figures/heatmap.js +395 -0
- package/dist/report-render/figures/index.d.ts +135 -0
- package/dist/report-render/figures/index.js +100 -0
- package/dist/report-render/figures/km.d.ts +16 -0
- package/dist/report-render/figures/km.js +406 -0
- package/dist/report-render/figures/label-room.d.ts +130 -0
- package/dist/report-render/figures/label-room.js +341 -0
- package/dist/report-render/figures/locuszoom.d.ts +50 -0
- package/dist/report-render/figures/locuszoom.js +675 -0
- package/dist/report-render/figures/lollipop.d.ts +16 -0
- package/dist/report-render/figures/lollipop.js +247 -0
- package/dist/report-render/figures/ma.d.ts +20 -0
- package/dist/report-render/figures/ma.js +114 -0
- package/dist/report-render/figures/manhattan.d.ts +60 -0
- package/dist/report-render/figures/manhattan.js +343 -0
- package/dist/report-render/figures/oncoprint.d.ts +41 -0
- package/dist/report-render/figures/oncoprint.js +420 -0
- package/dist/report-render/figures/pca.d.ts +37 -0
- package/dist/report-render/figures/pca.js +241 -0
- package/dist/report-render/figures/qq.d.ts +30 -0
- package/dist/report-render/figures/qq.js +182 -0
- package/dist/report-render/figures/roc.d.ts +17 -0
- package/dist/report-render/figures/roc.js +116 -0
- package/dist/report-render/figures/sankey.d.ts +48 -0
- package/dist/report-render/figures/sankey.js +353 -0
- package/dist/report-render/figures/upset.d.ts +60 -0
- package/dist/report-render/figures/upset.js +316 -0
- package/dist/report-render/figures/volcano.d.ts +25 -0
- package/dist/report-render/figures/volcano.js +166 -0
- package/dist/report-render/hybrid-svg.d.ts +75 -0
- package/dist/report-render/hybrid-svg.js +504 -0
- package/dist/report-render/number-format.d.ts +19 -0
- package/dist/report-render/number-format.js +25 -1
- package/dist/report-render/page.d.ts +41 -4
- package/dist/report-render/page.js +247 -12
- package/dist/report-render/render.d.ts +13 -4
- package/dist/report-render/render.js +37 -6
- package/dist/report-render/types.d.ts +23 -2
- package/dist/report-render/value-bridge.d.ts +38 -3
- package/dist/report-render/value-bridge.js +137 -6
- package/dist/report-render/views/chart-view.d.ts +42 -6
- package/dist/report-render/views/chart-view.js +70 -9
- package/dist/report-render/views/page-view.js +9 -10
- package/dist/runtime/assemble.js +2 -2
- package/dist/sandbox/client.d.ts +23 -32
- package/dist/sandbox/client.js +3 -11
- package/dist/sandbox/create-sandbox.d.ts +9 -24
- package/dist/sandbox/create-sandbox.js +15 -30
- package/dist/sandbox/docker-client.d.ts +12 -22
- package/dist/sandbox/docker-client.js +29 -43
- package/dist/sandbox/exec.d.ts +58 -0
- package/dist/sandbox/exec.js +197 -0
- package/dist/sandbox/identity.d.ts +5 -5
- package/dist/sandbox/identity.js +7 -10
- package/dist/sandbox/k8s-client.d.ts +4 -10
- package/dist/sandbox/k8s-client.js +5 -12
- package/dist/sandbox/liveness.d.ts +5 -12
- package/dist/sandbox/liveness.js +5 -12
- package/dist/sandbox/notification-sweep.d.ts +4 -7
- package/dist/sandbox/notification-sweep.js +4 -7
- package/dist/sandbox/reaper.d.ts +3 -3
- package/dist/sandbox/reaper.js +3 -3
- package/dist/sandbox/sandbox-error.d.ts +10 -11
- package/dist/sandbox/sandbox-error.js +10 -11
- package/dist/sandbox/sandbox-step-translate.d.ts +1 -1
- package/dist/sandbox/sandbox-step-translate.js +1 -1
- package/dist/sandbox/types.d.ts +31 -99
- package/dist/sandbox/types.js +17 -84
- package/dist/state/active-sandboxes.d.ts +7 -32
- package/dist/state/active-sandboxes.js +11 -46
- package/dist/state/index.d.ts +1 -2
- package/dist/state/index.js +1 -1
- package/dist/state/migrations/20261005120000_drop_the_active_exec_tracking.d.ts +7 -0
- package/dist/state/migrations/20261005120000_drop_the_active_exec_tracking.js +12 -0
- package/dist/state/migrations/index.js +2 -0
- package/dist/state/schema.d.ts +1 -5
- package/dist/state/schema.js +1 -6
- package/dist/state/step-executions.js +1 -2
- package/dist/tasks/data-profile.js +7 -20
- package/dist/tasks/derive-table-exec.d.ts +4 -14
- package/dist/tasks/derive-table-exec.js +9 -24
- package/dist/tasks/extract-values.d.ts +2 -2
- package/dist/tasks/extract-values.js +4 -7
- package/dist/tools/define-tool.d.ts +56 -13
- package/dist/tools/define-tool.js +28 -1
- package/dist/tools/execute-analysis.js +3 -3
- package/dist/tools/report-session/derive-table.d.ts +8 -9
- package/dist/tools/report-session/derive-table.js +3 -4
- package/dist/tools/report-session/preview-report.js +4 -49
- package/dist/tools/sandbox/list-available-packages.d.ts +1 -1
- package/dist/tools/sandbox/list-available-packages.js +5 -4
- package/dist/tools/workspace/edit-file.d.ts +5 -4
- package/dist/tools/workspace/edit-file.js +10 -13
- package/dist/tools/workspace/execute-command.d.ts +27 -42
- package/dist/tools/workspace/execute-command.js +42 -38
- package/dist/tools/workspace/index.d.ts +5 -6
- package/dist/tools/workspace/index.js +5 -6
- package/dist/tools/workspace/mutator.d.ts +43 -8
- package/dist/tools/workspace/mutator.js +45 -34
- package/dist/tools/workspace/run-exec.d.ts +3 -12
- package/dist/tools/workspace/run-exec.js +7 -24
- package/dist/tools/workspace/scan-inputs.d.ts +0 -3
- package/dist/tools/workspace/scan-inputs.js +0 -1
- package/dist/tools/workspace/write-file.d.ts +12 -3
- package/dist/tools/workspace/write-file.js +17 -13
- package/dist/workflows/sandbox-step.d.ts +7 -11
- package/dist/workflows/sandbox-step.js +24 -27
- package/package.json +3 -1
- package/dist/sandbox/await-exec.d.ts +0 -143
- package/dist/sandbox/await-exec.js +0 -417
- package/dist/sandbox/deliver-exec-event.d.ts +0 -25
- package/dist/sandbox/deliver-exec-event.js +0 -29
- package/dist/sandbox/digest.d.ts +0 -14
- package/dist/sandbox/digest.js +0 -17
- package/dist/sandbox/exec-id.d.ts +0 -12
- package/dist/sandbox/exec-id.js +0 -20
- package/dist/sandbox/hmac.d.ts +0 -62
- package/dist/sandbox/hmac.js +0 -72
- package/dist/sandbox/submit-exec.d.ts +0 -38
- package/dist/sandbox/submit-exec.js +0 -80
- package/dist/sandbox/watchdog.d.ts +0 -71
- package/dist/sandbox/watchdog.js +0 -161
|
@@ -0,0 +1,595 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The toolbox of a page chart: the download menu, the data view, and the zoom of a dense cartesian chart.
|
|
3
|
+
*
|
|
4
|
+
* The derivation gives a figure with no toolbox. The chart card adds the toolbox to the option of the page, and
|
|
5
|
+
* each export removes it again, thus a file never shows it. The option rides to the page as inline JSON, thus
|
|
6
|
+
* it holds no function. Each handler of the toolbox is the name of a page function, and the bootstrap binds the
|
|
7
|
+
* function under that name after the parse, as it registers a named renderer.
|
|
8
|
+
*
|
|
9
|
+
* The toolbox holds no `magicType`, because a reader must not change the form that the author chose.
|
|
10
|
+
*/
|
|
11
|
+
import { CHART_INK, CHART_TOOLBOX_ACTIVE_COLOR, CHART_TOOLBOX_FONT, CHART_TOOLBOX_ICON_COLOR } from "./design.js";
|
|
12
|
+
/**
|
|
13
|
+
* The chart types that get the zoom and the restore controls: the dense cartesian forms. A reader zooms into a
|
|
14
|
+
* cloud of many thousands of points to read one region.
|
|
15
|
+
*/
|
|
16
|
+
export const DENSE_CARTESIAN_CHARTS = ["scatter", "embedding", "volcano", "ma", "manhattan", "qq", "locuszoom"];
|
|
17
|
+
/** The page function that opens the download menu of a chart, and the page function that gives the data view. */
|
|
18
|
+
export const EXPORT_MENU_FUNCTION = "reportOpenExportMenu";
|
|
19
|
+
export const DATA_VIEW_FUNCTION = "reportDataViewContent";
|
|
20
|
+
/**
|
|
21
|
+
* The members of a toolbox feature that name a page function. The bootstrap replaces each name with its
|
|
22
|
+
* function, and it removes a name that the page does not hold, because the runtime calls the member.
|
|
23
|
+
*/
|
|
24
|
+
export const TOOLBOX_FUNCTION_MEMBERS = ["onclick", "optionToContent"];
|
|
25
|
+
/** The names of the page functions that a toolbox can name. Each one is a function of `CHART_TOOLBOX_SOURCE`. */
|
|
26
|
+
export const TOOLBOX_PAGE_FUNCTIONS = [EXPORT_MENU_FUNCTION, DATA_VIEW_FUNCTION];
|
|
27
|
+
/** The download icon: an arrow into a tray, as the path of a 24-pixel box. The runtime strokes it in the icon color. */
|
|
28
|
+
export const DOWNLOAD_ICON = "path://M12 3L12 15M7 10L12 15L17 10M4 17L4 21L20 21L20 17";
|
|
29
|
+
/**
|
|
30
|
+
* The place of the toolbox in the chart body, in pixels: the gap to the right edge and to the top edge, the
|
|
31
|
+
* padding of the toolbox box, the size of one icon, and the gap between two icons.
|
|
32
|
+
*/
|
|
33
|
+
const TOOLBOX_RIGHT_PX = 4;
|
|
34
|
+
const TOOLBOX_TOP_PX = 0;
|
|
35
|
+
const TOOLBOX_PADDING_PX = 5;
|
|
36
|
+
const TOOLBOX_ITEM_PX = 14;
|
|
37
|
+
const TOOLBOX_ITEM_GAP_PX = 12;
|
|
38
|
+
/**
|
|
39
|
+
* The canvas layer of the toolbox. The print hides this layer, because a new option draws each series again and
|
|
40
|
+
* a dense series then draws in chunks over some frames. The runtime gives a dense series a layer of its own and
|
|
41
|
+
* lifts each later component one layer, thus the toolbox stands far above each layer that the runtime gives.
|
|
42
|
+
*/
|
|
43
|
+
export const TOOLBOX_ZLEVEL = 1000;
|
|
44
|
+
/** The width of an icon stroke, in pixels. */
|
|
45
|
+
const TOOLBOX_STROKE_PX = 1.25;
|
|
46
|
+
/**
|
|
47
|
+
* The least hit width of an outline, in pixels. The runtime measures a path with a stroke and no fill with its
|
|
48
|
+
* hit area, thus the box of each toolbox icon is this width larger than the icon.
|
|
49
|
+
*/
|
|
50
|
+
const OUTLINE_HIT_PX = 5;
|
|
51
|
+
/**
|
|
52
|
+
* The height of the band that the toolbox takes at the top of the chart body, in pixels: the top gap, the
|
|
53
|
+
* padding over and under the icons, and the box of one outline icon. The derivation gives no toolbox, and no
|
|
54
|
+
* layer reserves this band, thus a figure that places its own grid keeps its plot and its text under the band.
|
|
55
|
+
*/
|
|
56
|
+
export const TOOLBOX_BAND_PX = TOOLBOX_TOP_PX + 2 * TOOLBOX_PADDING_PX + TOOLBOX_ITEM_PX + Math.max(TOOLBOX_STROKE_PX, OUTLINE_HIT_PX);
|
|
57
|
+
/** The size of the title text that the runtime shows under an icon on hover, in pixels. */
|
|
58
|
+
const TOOLBOX_TITLE_PX = 10;
|
|
59
|
+
/** The gap between the download icon and the top edge of its menu, in pixels. */
|
|
60
|
+
const MENU_GAP_PX = 4;
|
|
61
|
+
/** The suffix of the id of a download menu. The menu of a chart takes the id of its container and this suffix. */
|
|
62
|
+
const MENU_ID_SUFFIX = "-menu";
|
|
63
|
+
/** The suffix of the id of the download control of a card. The control takes the id of its container and this suffix. */
|
|
64
|
+
const MENU_CONTROL_SUFFIX = "-download";
|
|
65
|
+
/** The attribute of the download control of a card. It holds the id of the container whose menu the control opens. */
|
|
66
|
+
export const MENU_CONTROL_ATTRIBUTE = "data-chart-menu";
|
|
67
|
+
/** The class of an open download menu. The design sheet shows a menu with this class, and it hides each other menu. */
|
|
68
|
+
export const MENU_OPEN_CLASS = "report-chart-menu-open";
|
|
69
|
+
/** The class of the hidden note that a menu shows when the page cannot build the file of an entry. */
|
|
70
|
+
export const MENU_FAULT_CLASS = "report-chart-menu-fault";
|
|
71
|
+
/** The class of a fault note that the page shows. The design sheet hides each other fault note. */
|
|
72
|
+
export const MENU_FAULT_SHOWN_CLASS = "report-chart-menu-fault-shown";
|
|
73
|
+
/**
|
|
74
|
+
* The most rows that the data view shows. A dense chart plots many thousands of points, and a table of each one
|
|
75
|
+
* costs the page a DOM node for each cell. The note of the view then states the count that it holds back.
|
|
76
|
+
*/
|
|
77
|
+
export const DATA_VIEW_ROW_LIMIT = 1000;
|
|
78
|
+
/** The texts of the data view: the heading, the close control, and the refresh control that a read-only view hides. */
|
|
79
|
+
const DATA_VIEW_LANG = ["Data", "Close", "Refresh"];
|
|
80
|
+
/** The id of the download menu of the chart in one container. */
|
|
81
|
+
export function chartMenuId(containerId) {
|
|
82
|
+
return `${containerId}${MENU_ID_SUFFIX}`;
|
|
83
|
+
}
|
|
84
|
+
/** The id of the download control in the card of the chart in one container. */
|
|
85
|
+
export function chartMenuControlId(containerId) {
|
|
86
|
+
return `${containerId}${MENU_CONTROL_SUFFIX}`;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* The toolbox of one page chart.
|
|
90
|
+
*
|
|
91
|
+
* Each chart gets the data view and the download control. A dense cartesian chart also gets the zoom and the
|
|
92
|
+
* restore controls. A composition names no chart type, thus it gets no zoom. The download control is the last
|
|
93
|
+
* feature, thus it sits at the right edge and its menu opens under it.
|
|
94
|
+
*/
|
|
95
|
+
export function chartToolbox(chartType) {
|
|
96
|
+
const dense = chartType !== undefined && DENSE_CARTESIAN_CHARTS.includes(chartType);
|
|
97
|
+
return {
|
|
98
|
+
show: true,
|
|
99
|
+
zlevel: TOOLBOX_ZLEVEL,
|
|
100
|
+
right: TOOLBOX_RIGHT_PX,
|
|
101
|
+
top: TOOLBOX_TOP_PX,
|
|
102
|
+
padding: TOOLBOX_PADDING_PX,
|
|
103
|
+
itemSize: TOOLBOX_ITEM_PX,
|
|
104
|
+
itemGap: TOOLBOX_ITEM_GAP_PX,
|
|
105
|
+
iconStyle: { borderColor: CHART_TOOLBOX_ICON_COLOR, borderWidth: TOOLBOX_STROKE_PX },
|
|
106
|
+
emphasis: {
|
|
107
|
+
iconStyle: {
|
|
108
|
+
borderColor: CHART_TOOLBOX_ACTIVE_COLOR,
|
|
109
|
+
textFill: CHART_TOOLBOX_ACTIVE_COLOR,
|
|
110
|
+
textFontFamily: CHART_TOOLBOX_FONT,
|
|
111
|
+
textFontSize: TOOLBOX_TITLE_PX,
|
|
112
|
+
},
|
|
113
|
+
},
|
|
114
|
+
feature: {
|
|
115
|
+
...(dense
|
|
116
|
+
? {
|
|
117
|
+
dataZoom: { show: true, title: { zoom: "Zoom", back: "Undo zoom" }, filterMode: "none" },
|
|
118
|
+
restore: { show: true, title: "Restore" },
|
|
119
|
+
}
|
|
120
|
+
: {}),
|
|
121
|
+
dataView: {
|
|
122
|
+
show: true,
|
|
123
|
+
title: "Data",
|
|
124
|
+
readOnly: true,
|
|
125
|
+
lang: [...DATA_VIEW_LANG],
|
|
126
|
+
optionToContent: DATA_VIEW_FUNCTION,
|
|
127
|
+
backgroundColor: "#ffffff",
|
|
128
|
+
textColor: CHART_INK,
|
|
129
|
+
buttonColor: CHART_TOOLBOX_ACTIVE_COLOR,
|
|
130
|
+
buttonTextColor: "#ffffff",
|
|
131
|
+
},
|
|
132
|
+
myExport: { show: true, title: "Download", icon: DOWNLOAD_ICON, onclick: EXPORT_MENU_FUNCTION },
|
|
133
|
+
},
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
/** The option of the page: the derived option with the toolbox of its chart type. The derived option stays as it is. */
|
|
137
|
+
export function pageChartOption(option, chartType) {
|
|
138
|
+
return { ...option, toolbox: chartToolbox(chartType) };
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* The page function that makes the label formatter of a genome axis, and the member of the axis that it reads.
|
|
142
|
+
*
|
|
143
|
+
* A genome axis plots the cumulative position over the chromosomes. At the full range a series names the
|
|
144
|
+
* chromosomes, and the axis hides its labels. While a zoom of the toolbox narrows the axis, the axis shows each
|
|
145
|
+
* position as the chromosome and the position on it, and that series hides.
|
|
146
|
+
*/
|
|
147
|
+
export const GENOME_POSITION_FUNCTION = "reportGenomePosition";
|
|
148
|
+
export const GENOME_MEMBER = "genome";
|
|
149
|
+
/** The bases in one megabase, the unit of a position on a genome axis. */
|
|
150
|
+
const BASES_PER_MEGABASE = 1e6;
|
|
151
|
+
/** The decimals of a position on a genome axis, in megabases: one kilobase. */
|
|
152
|
+
const GENOME_POSITION_DIGITS = 3;
|
|
153
|
+
/**
|
|
154
|
+
* The page functions of the toolbox, as browser source text.
|
|
155
|
+
*
|
|
156
|
+
* `reportOpenExportMenu` is the click handler of the download icon of the toolbox. The runtime calls it with the
|
|
157
|
+
* model, the API of the chart, the name of the icon, and the event. The runtime draws the icon on the canvas and
|
|
158
|
+
* binds a mouse click alone, thus the card also carries a download control in its title line. `reportMenuClick`
|
|
159
|
+
* takes a click on that control, and a button fires a click for the Enter key and the Space key. The two paths
|
|
160
|
+
* open the menu of the chart under the icon, at the right edge of the chart body, and a second click closes it.
|
|
161
|
+
* The control states the open menu in `aria-expanded`.
|
|
162
|
+
*
|
|
163
|
+
* The menu takes the keyboard: the first entry takes the focus, the arrow keys, `Home`, and `End` move the focus,
|
|
164
|
+
* and `Escape` closes the menu and gives the focus back to the control of the card. `Tab` closes the menu and puts
|
|
165
|
+
* the focus on the control, thus the next Tab stop comes after the control. A click outside the menu closes it,
|
|
166
|
+
* and so does a click on an entry. After an entry fires, the focus goes back to the control.
|
|
167
|
+
*
|
|
168
|
+
* The runtime sends the click of the icon on to the document, and that click is outside the menu. Thus the menu
|
|
169
|
+
* keeps the event that opened it, and the outside test skips that one event. On a touch screen the runtime fires
|
|
170
|
+
* the click of the icon from the touch end, and the browser then sends its own click to the chart. Thus a menu that
|
|
171
|
+
* a tap opened also skips the next click inside its chart.
|
|
172
|
+
*
|
|
173
|
+
* `reportMenuFault` shows the fault note of the open menu and gives it the focus, when the page cannot build the
|
|
174
|
+
* file of an entry. The menu then stays open, and the close hides the note again.
|
|
175
|
+
*
|
|
176
|
+
* `reportDataViewContent` gives the data view: the plotted rows of each series as one plain table, up to the row
|
|
177
|
+
* limit. A series that the reader cannot hover, for example the anchors of the point names, holds no data of the
|
|
178
|
+
* figure, thus the table skips it. A number of a category axis reads as its category. The view builds each cell
|
|
179
|
+
* as text, thus a hostile name reaches the view as text and never as markup.
|
|
180
|
+
*
|
|
181
|
+
* `reportBindToolbox` replaces each function name of the toolbox with its page function. It also replaces the name
|
|
182
|
+
* of the formatter of each genome axis with the formatter that `reportGenomePosition` makes from the genome member
|
|
183
|
+
* of the axis. The formatter gives the label of the chromosome that holds the position, and the distance from the
|
|
184
|
+
* start of that chromosome in megabases.
|
|
185
|
+
*
|
|
186
|
+
* `reportWatchZoom` attaches the zoom handler to a chart after its init. The handler reads the window of each
|
|
187
|
+
* axis after each zoom. The toolbox zoom fixes the ends of a zoomed axis to the ends of the selected box, and the
|
|
188
|
+
* runtime prints each end of a value axis as a label beside the round labels. Thus a zoomed value axis hides
|
|
189
|
+
* its two end labels, and a genome axis shows its labels and hides the series that names the chromosomes. That
|
|
190
|
+
* series draws one point under the middle of each chromosome, and a zoom clips each point outside the window.
|
|
191
|
+
* At the full range each value goes back to the value of the option. The restore of the toolbox sets the option
|
|
192
|
+
* of the chart again, thus the handler then starts from the option.
|
|
193
|
+
*/
|
|
194
|
+
export const CHART_TOOLBOX_SOURCE = `var reportMenuOpen = null;
|
|
195
|
+
var reportMenuEvent = null;
|
|
196
|
+
var reportMenuTap = null;
|
|
197
|
+
var reportMenuFocus = null;
|
|
198
|
+
var reportMenuControl = null;
|
|
199
|
+
var reportMenuRight = 0;
|
|
200
|
+
function reportToolboxList(member) {
|
|
201
|
+
if (member === undefined || member === null) {
|
|
202
|
+
return [];
|
|
203
|
+
}
|
|
204
|
+
return Array.isArray(member) ? member : [member];
|
|
205
|
+
}
|
|
206
|
+
function reportMenuItems(menu) {
|
|
207
|
+
return menu.querySelectorAll('[role="menuitem"]:not([aria-disabled="true"])');
|
|
208
|
+
}
|
|
209
|
+
function reportCloseExportMenu(restore) {
|
|
210
|
+
var menu = reportMenuOpen;
|
|
211
|
+
if (menu === null) {
|
|
212
|
+
return;
|
|
213
|
+
}
|
|
214
|
+
menu.classList.remove(${JSON.stringify(MENU_OPEN_CLASS)});
|
|
215
|
+
var fault = menu.querySelector(${JSON.stringify(`.${MENU_FAULT_CLASS}`)});
|
|
216
|
+
if (fault) {
|
|
217
|
+
fault.classList.remove(${JSON.stringify(MENU_FAULT_SHOWN_CLASS)});
|
|
218
|
+
}
|
|
219
|
+
if (reportMenuControl) {
|
|
220
|
+
reportMenuControl.setAttribute("aria-expanded", "false");
|
|
221
|
+
}
|
|
222
|
+
reportMenuOpen = null;
|
|
223
|
+
reportMenuEvent = null;
|
|
224
|
+
reportMenuTap = null;
|
|
225
|
+
reportMenuControl = null;
|
|
226
|
+
var focus = reportMenuFocus;
|
|
227
|
+
reportMenuFocus = null;
|
|
228
|
+
if (restore && focus && typeof focus.focus === "function") {
|
|
229
|
+
focus.focus();
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
function reportToggleExportMenu(container, event) {
|
|
233
|
+
var menu = container && container.id ? document.getElementById(container.id + ${JSON.stringify(MENU_ID_SUFFIX)}) : null;
|
|
234
|
+
if (!menu) {
|
|
235
|
+
return;
|
|
236
|
+
}
|
|
237
|
+
if (reportMenuOpen === menu) {
|
|
238
|
+
reportCloseExportMenu(true);
|
|
239
|
+
return;
|
|
240
|
+
}
|
|
241
|
+
reportCloseExportMenu(false);
|
|
242
|
+
menu.classList.add(${JSON.stringify(MENU_OPEN_CLASS)});
|
|
243
|
+
// The download control is the last icon, thus its right edge sits at the right gap and the padding of the
|
|
244
|
+
// toolbox from the right edge of the chart body.
|
|
245
|
+
reportMenuRight = container.offsetLeft + container.clientWidth - ${TOOLBOX_RIGHT_PX + TOOLBOX_PADDING_PX};
|
|
246
|
+
var left = reportMenuRight - menu.offsetWidth;
|
|
247
|
+
menu.style.left = (left > 0 ? left : 0) + "px";
|
|
248
|
+
menu.style.top = container.offsetTop + ${TOOLBOX_TOP_PX + TOOLBOX_PADDING_PX + TOOLBOX_ITEM_PX + MENU_GAP_PX} + "px";
|
|
249
|
+
reportMenuOpen = menu;
|
|
250
|
+
reportMenuEvent = event;
|
|
251
|
+
reportMenuTap = event && event.type === "touchend" ? container : null;
|
|
252
|
+
reportMenuControl = document.getElementById(container.id + ${JSON.stringify(MENU_CONTROL_SUFFIX)});
|
|
253
|
+
reportMenuFocus = reportMenuControl || document.activeElement;
|
|
254
|
+
if (reportMenuControl) {
|
|
255
|
+
reportMenuControl.setAttribute("aria-expanded", "true");
|
|
256
|
+
}
|
|
257
|
+
var items = reportMenuItems(menu);
|
|
258
|
+
if (items.length > 0) {
|
|
259
|
+
items[0].focus();
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
function reportOpenExportMenu(ecModel, api, iconName, event) {
|
|
263
|
+
reportToggleExportMenu(api.getDom(), event && event.event ? event.event : null);
|
|
264
|
+
}
|
|
265
|
+
function reportMenuFault(entry) {
|
|
266
|
+
var menu = entry && typeof entry.closest === "function" ? entry.closest('[role="menu"]') : null;
|
|
267
|
+
var fault = menu ? menu.querySelector(${JSON.stringify(`.${MENU_FAULT_CLASS}`)}) : null;
|
|
268
|
+
if (!fault) {
|
|
269
|
+
return;
|
|
270
|
+
}
|
|
271
|
+
fault.classList.add(${JSON.stringify(MENU_FAULT_SHOWN_CLASS)});
|
|
272
|
+
if (menu === reportMenuOpen) {
|
|
273
|
+
var left = reportMenuRight - menu.offsetWidth;
|
|
274
|
+
menu.style.left = (left > 0 ? left : 0) + "px";
|
|
275
|
+
}
|
|
276
|
+
fault.focus();
|
|
277
|
+
}
|
|
278
|
+
function reportMenuClick(event) {
|
|
279
|
+
var target = event.target;
|
|
280
|
+
var control = target && typeof target.closest === "function" ? target.closest(${JSON.stringify(`[${MENU_CONTROL_ATTRIBUTE}]`)}) : null;
|
|
281
|
+
if (control) {
|
|
282
|
+
reportToggleExportMenu(document.getElementById(control.getAttribute(${JSON.stringify(MENU_CONTROL_ATTRIBUTE)}) || ""), event);
|
|
283
|
+
return;
|
|
284
|
+
}
|
|
285
|
+
if (reportMenuOpen === null || event === reportMenuEvent) {
|
|
286
|
+
return;
|
|
287
|
+
}
|
|
288
|
+
var tapped = reportMenuTap;
|
|
289
|
+
reportMenuTap = null;
|
|
290
|
+
if (tapped && target && typeof tapped.contains === "function" && tapped.contains(target)) {
|
|
291
|
+
return;
|
|
292
|
+
}
|
|
293
|
+
var inside = target && typeof target.closest === "function" ? target.closest('[role="menu"]') : null;
|
|
294
|
+
if (inside === reportMenuOpen) {
|
|
295
|
+
var item = target.closest('[role="menuitem"]');
|
|
296
|
+
if (!item || item.getAttribute("aria-disabled") === "true") {
|
|
297
|
+
return;
|
|
298
|
+
}
|
|
299
|
+
// The entry fired, and the menu that held the focus closes, thus the focus goes back to the control.
|
|
300
|
+
reportCloseExportMenu(true);
|
|
301
|
+
return;
|
|
302
|
+
}
|
|
303
|
+
reportCloseExportMenu(false);
|
|
304
|
+
}
|
|
305
|
+
function reportMenuKey(event) {
|
|
306
|
+
var menu = reportMenuOpen;
|
|
307
|
+
if (menu === null) {
|
|
308
|
+
return;
|
|
309
|
+
}
|
|
310
|
+
if (event.key === "Escape") {
|
|
311
|
+
event.preventDefault();
|
|
312
|
+
reportCloseExportMenu(true);
|
|
313
|
+
return;
|
|
314
|
+
}
|
|
315
|
+
if (event.key === "Tab") {
|
|
316
|
+
reportCloseExportMenu(true);
|
|
317
|
+
return;
|
|
318
|
+
}
|
|
319
|
+
var items = reportMenuItems(menu);
|
|
320
|
+
if (items.length === 0) {
|
|
321
|
+
return;
|
|
322
|
+
}
|
|
323
|
+
var at = -1;
|
|
324
|
+
for (var i = 0; i < items.length; i++) {
|
|
325
|
+
if (items[i] === document.activeElement) {
|
|
326
|
+
at = i;
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
var next = -1;
|
|
330
|
+
if (event.key === "ArrowDown") {
|
|
331
|
+
next = at < 0 || at === items.length - 1 ? 0 : at + 1;
|
|
332
|
+
} else if (event.key === "ArrowUp") {
|
|
333
|
+
next = at <= 0 ? items.length - 1 : at - 1;
|
|
334
|
+
} else if (event.key === "Home") {
|
|
335
|
+
next = 0;
|
|
336
|
+
} else if (event.key === "End") {
|
|
337
|
+
next = items.length - 1;
|
|
338
|
+
}
|
|
339
|
+
if (next >= 0) {
|
|
340
|
+
event.preventDefault();
|
|
341
|
+
items[next].focus();
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
function reportCategoryCell(axis, cell) {
|
|
345
|
+
if (!axis || axis.type !== "category" || !Array.isArray(axis.data) || typeof cell !== "number" || cell % 1 !== 0 || cell < 0 || cell >= axis.data.length) {
|
|
346
|
+
return cell;
|
|
347
|
+
}
|
|
348
|
+
var entry = axis.data[cell];
|
|
349
|
+
return typeof entry === "object" && entry !== null ? entry.value : entry;
|
|
350
|
+
}
|
|
351
|
+
function reportViewCell(cell) {
|
|
352
|
+
if (cell === null || cell === undefined || cell === "-") {
|
|
353
|
+
return "";
|
|
354
|
+
}
|
|
355
|
+
if (typeof cell === "number") {
|
|
356
|
+
return isFinite(cell) ? String(Number.isInteger(cell) ? cell : Number(cell.toPrecision(6))) : "";
|
|
357
|
+
}
|
|
358
|
+
return String(cell);
|
|
359
|
+
}
|
|
360
|
+
function reportDataViewRows(option, limit) {
|
|
361
|
+
var series = reportToolboxList(option.series);
|
|
362
|
+
var xAxes = reportToolboxList(option.xAxis);
|
|
363
|
+
var yAxes = reportToolboxList(option.yAxis);
|
|
364
|
+
var rows = [];
|
|
365
|
+
var total = 0;
|
|
366
|
+
var named = false;
|
|
367
|
+
var width = 0;
|
|
368
|
+
var heads = null;
|
|
369
|
+
function keep(seriesName, itemName, cells) {
|
|
370
|
+
total += 1;
|
|
371
|
+
if (rows.length >= limit) {
|
|
372
|
+
return;
|
|
373
|
+
}
|
|
374
|
+
if (itemName !== "") {
|
|
375
|
+
named = true;
|
|
376
|
+
}
|
|
377
|
+
if (cells.length > width) {
|
|
378
|
+
width = cells.length;
|
|
379
|
+
}
|
|
380
|
+
rows.push([seriesName, itemName].concat(cells));
|
|
381
|
+
}
|
|
382
|
+
for (var s = 0; s < series.length; s++) {
|
|
383
|
+
var entry = series[s];
|
|
384
|
+
if (!entry || entry.silent === true || (entry.tooltip && entry.tooltip.show === false)) {
|
|
385
|
+
continue;
|
|
386
|
+
}
|
|
387
|
+
var seriesName = entry.name === undefined || entry.name === null ? "" : String(entry.name);
|
|
388
|
+
if (Array.isArray(entry.links)) {
|
|
389
|
+
for (var l = 0; l < entry.links.length; l++) {
|
|
390
|
+
var link = entry.links[l];
|
|
391
|
+
keep(seriesName, reportViewCell(link.source) + " → " + reportViewCell(link.target), [reportViewCell(link.value)]);
|
|
392
|
+
}
|
|
393
|
+
continue;
|
|
394
|
+
}
|
|
395
|
+
var data = Array.isArray(entry.data) ? entry.data : [];
|
|
396
|
+
var xAxis = xAxes[typeof entry.xAxisIndex === "number" ? entry.xAxisIndex : 0];
|
|
397
|
+
var yAxis = yAxes[typeof entry.yAxisIndex === "number" ? entry.yAxisIndex : 0];
|
|
398
|
+
var cartesian = entry.coordinateSystem === undefined || entry.coordinateSystem === "cartesian2d";
|
|
399
|
+
if (cartesian && heads === null && xAxis && yAxis) {
|
|
400
|
+
heads = [xAxis.name ? String(xAxis.name) : "x", yAxis.name ? String(yAxis.name) : "y"];
|
|
401
|
+
}
|
|
402
|
+
for (var i = 0; i < data.length; i++) {
|
|
403
|
+
var item = data[i];
|
|
404
|
+
var boxed = typeof item === "object" && item !== null && !Array.isArray(item);
|
|
405
|
+
var value = boxed ? item.value : item;
|
|
406
|
+
var itemName = boxed && item.name !== undefined && item.name !== null ? String(item.name) : "";
|
|
407
|
+
var cells = [];
|
|
408
|
+
if (Array.isArray(value)) {
|
|
409
|
+
for (var d = 0; d < value.length; d++) {
|
|
410
|
+
var axis = !cartesian ? null : d === 0 ? xAxis : d === 1 ? yAxis : null;
|
|
411
|
+
cells.push(reportViewCell(reportCategoryCell(axis, value[d])));
|
|
412
|
+
}
|
|
413
|
+
} else if (cartesian && xAxis && xAxis.type === "category") {
|
|
414
|
+
cells = [reportViewCell(reportCategoryCell(xAxis, i)), reportViewCell(value)];
|
|
415
|
+
} else if (cartesian && yAxis && yAxis.type === "category") {
|
|
416
|
+
cells = [reportViewCell(value), reportViewCell(reportCategoryCell(yAxis, i))];
|
|
417
|
+
} else {
|
|
418
|
+
cells = [reportViewCell(value)];
|
|
419
|
+
}
|
|
420
|
+
keep(seriesName, itemName, cells);
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
var columns = ["Series"];
|
|
424
|
+
if (named) {
|
|
425
|
+
columns.push("Name");
|
|
426
|
+
}
|
|
427
|
+
for (var c = 0; c < width; c++) {
|
|
428
|
+
columns.push(heads !== null && c < heads.length ? heads[c] : c === 0 ? "Value" : "Value " + (c + 1));
|
|
429
|
+
}
|
|
430
|
+
var shaped = [];
|
|
431
|
+
for (var r = 0; r < rows.length; r++) {
|
|
432
|
+
var row = named ? rows[r].slice(0) : [rows[r][0]].concat(rows[r].slice(2));
|
|
433
|
+
while (row.length < columns.length) {
|
|
434
|
+
row.push("");
|
|
435
|
+
}
|
|
436
|
+
shaped.push(row);
|
|
437
|
+
}
|
|
438
|
+
return { columns: columns, rows: shaped, total: total };
|
|
439
|
+
}
|
|
440
|
+
function reportDataViewContent(option) {
|
|
441
|
+
var view = reportDataViewRows(option, ${DATA_VIEW_ROW_LIMIT});
|
|
442
|
+
var root = document.createElement("div");
|
|
443
|
+
root.className = "report-data-view";
|
|
444
|
+
if (view.total > view.rows.length) {
|
|
445
|
+
var note = document.createElement("p");
|
|
446
|
+
note.className = "report-data-view-note";
|
|
447
|
+
note.textContent = "The view shows the first " + view.rows.length.toLocaleString("en-US") + " of " + view.total.toLocaleString("en-US") + " rows.";
|
|
448
|
+
root.appendChild(note);
|
|
449
|
+
}
|
|
450
|
+
var table = document.createElement("table");
|
|
451
|
+
var head = document.createElement("thead");
|
|
452
|
+
var headRow = document.createElement("tr");
|
|
453
|
+
for (var c = 0; c < view.columns.length; c++) {
|
|
454
|
+
var th = document.createElement("th");
|
|
455
|
+
th.textContent = view.columns[c];
|
|
456
|
+
headRow.appendChild(th);
|
|
457
|
+
}
|
|
458
|
+
head.appendChild(headRow);
|
|
459
|
+
table.appendChild(head);
|
|
460
|
+
var body = document.createElement("tbody");
|
|
461
|
+
for (var r = 0; r < view.rows.length; r++) {
|
|
462
|
+
var tr = document.createElement("tr");
|
|
463
|
+
for (var k = 0; k < view.rows[r].length; k++) {
|
|
464
|
+
var td = document.createElement("td");
|
|
465
|
+
td.textContent = view.rows[r][k];
|
|
466
|
+
tr.appendChild(td);
|
|
467
|
+
}
|
|
468
|
+
body.appendChild(tr);
|
|
469
|
+
}
|
|
470
|
+
table.appendChild(body);
|
|
471
|
+
root.appendChild(table);
|
|
472
|
+
return root;
|
|
473
|
+
}
|
|
474
|
+
function reportGenomePosition(genome) {
|
|
475
|
+
var starts = genome && Array.isArray(genome.starts) ? genome.starts : [];
|
|
476
|
+
return function (value) {
|
|
477
|
+
var at = -1;
|
|
478
|
+
for (var c = 0; c < starts.length && (c === 0 || starts[c][0] < value); c++) {
|
|
479
|
+
at = c;
|
|
480
|
+
}
|
|
481
|
+
if (at < 0) {
|
|
482
|
+
return String(value);
|
|
483
|
+
}
|
|
484
|
+
return starts[at][1] + ": " + Number(((value - starts[at][0]) / ${BASES_PER_MEGABASE}).toFixed(${GENOME_POSITION_DIGITS})) + " Mb";
|
|
485
|
+
};
|
|
486
|
+
}
|
|
487
|
+
var reportToolboxFunctions = { ${TOOLBOX_PAGE_FUNCTIONS.map((name) => `${name}: ${name}`).join(", ")} };
|
|
488
|
+
function reportBindToolbox(option) {
|
|
489
|
+
var axes = reportToolboxList(option.xAxis).concat(reportToolboxList(option.yAxis));
|
|
490
|
+
for (var a = 0; a < axes.length; a++) {
|
|
491
|
+
var label = axes[a] ? axes[a].axisLabel : null;
|
|
492
|
+
if (label && label.formatter === ${JSON.stringify(GENOME_POSITION_FUNCTION)}) {
|
|
493
|
+
label.formatter = reportGenomePosition(axes[a][${JSON.stringify(GENOME_MEMBER)}]);
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
var toolbox = option.toolbox;
|
|
497
|
+
var features = toolbox && typeof toolbox === "object" ? toolbox.feature : null;
|
|
498
|
+
if (!features || typeof features !== "object") {
|
|
499
|
+
return;
|
|
500
|
+
}
|
|
501
|
+
var members = ${JSON.stringify(TOOLBOX_FUNCTION_MEMBERS)};
|
|
502
|
+
for (var name in features) {
|
|
503
|
+
if (!Object.prototype.hasOwnProperty.call(features, name) || !features[name]) {
|
|
504
|
+
continue;
|
|
505
|
+
}
|
|
506
|
+
for (var m = 0; m < members.length; m++) {
|
|
507
|
+
var bound = features[name][members[m]];
|
|
508
|
+
if (typeof bound !== "string") {
|
|
509
|
+
continue;
|
|
510
|
+
}
|
|
511
|
+
if (Object.prototype.hasOwnProperty.call(reportToolboxFunctions, bound)) {
|
|
512
|
+
features[name][members[m]] = reportToolboxFunctions[bound];
|
|
513
|
+
} else {
|
|
514
|
+
delete features[name][members[m]];
|
|
515
|
+
}
|
|
516
|
+
}
|
|
517
|
+
}
|
|
518
|
+
}
|
|
519
|
+
function reportZoomedAxes(chart) {
|
|
520
|
+
var zoomed = { xAxis: [], yAxis: [] };
|
|
521
|
+
chart.getModel().eachComponent("dataZoom", function (zoom) {
|
|
522
|
+
var range = zoom.getPercentRange();
|
|
523
|
+
if (!range || (range[0] <= 0 && range[1] >= 100)) {
|
|
524
|
+
return;
|
|
525
|
+
}
|
|
526
|
+
zoom.eachTargetAxis(function (dimension, index) {
|
|
527
|
+
var axes = zoomed[dimension + "Axis"];
|
|
528
|
+
if (axes) {
|
|
529
|
+
axes[index] = true;
|
|
530
|
+
}
|
|
531
|
+
});
|
|
532
|
+
});
|
|
533
|
+
return zoomed;
|
|
534
|
+
}
|
|
535
|
+
function reportOptionValue(value) {
|
|
536
|
+
return value === undefined ? null : value;
|
|
537
|
+
}
|
|
538
|
+
function reportZoomPatch(chart, option, zoomed) {
|
|
539
|
+
var model = chart.getModel();
|
|
540
|
+
var series = reportToolboxList(option.series);
|
|
541
|
+
var patch = { xAxis: [], yAxis: [] };
|
|
542
|
+
var named = [];
|
|
543
|
+
var mainTypes = ["xAxis", "yAxis"];
|
|
544
|
+
for (var t = 0; t < mainTypes.length; t++) {
|
|
545
|
+
var axes = reportToolboxList(option[mainTypes[t]]);
|
|
546
|
+
for (var a = 0; a < axes.length; a++) {
|
|
547
|
+
var axis = axes[a] || {};
|
|
548
|
+
var label = axis.axisLabel || {};
|
|
549
|
+
var zoom = zoomed[mainTypes[t]][a] === true;
|
|
550
|
+
var entry = {};
|
|
551
|
+
var axisModel = model.getComponent(mainTypes[t], a);
|
|
552
|
+
if (axisModel && axisModel.axis && axisModel.axis.type === "value") {
|
|
553
|
+
entry.showMinLabel = zoom ? false : reportOptionValue(label.showMinLabel);
|
|
554
|
+
entry.showMaxLabel = zoom ? false : reportOptionValue(label.showMaxLabel);
|
|
555
|
+
}
|
|
556
|
+
var genome = axis[${JSON.stringify(GENOME_MEMBER)}];
|
|
557
|
+
if (genome && typeof genome === "object") {
|
|
558
|
+
entry.show = zoom ? true : reportOptionValue(label.show);
|
|
559
|
+
for (var s = 0; s < series.length; s++) {
|
|
560
|
+
if (series[s] && series[s].name === genome.names) {
|
|
561
|
+
var names = series[s].label || {};
|
|
562
|
+
named.push({ name: genome.names, label: { show: zoom ? false : reportOptionValue(names.show) } });
|
|
563
|
+
}
|
|
564
|
+
}
|
|
565
|
+
}
|
|
566
|
+
patch[mainTypes[t]].push({ axisLabel: entry });
|
|
567
|
+
}
|
|
568
|
+
}
|
|
569
|
+
if (named.length > 0) {
|
|
570
|
+
patch.series = named;
|
|
571
|
+
}
|
|
572
|
+
return patch;
|
|
573
|
+
}
|
|
574
|
+
function reportWatchZoom(chart, option) {
|
|
575
|
+
var toolbox = option.toolbox;
|
|
576
|
+
var features = toolbox && typeof toolbox === "object" ? toolbox.feature : null;
|
|
577
|
+
if (!features || typeof features !== "object" || !features.dataZoom) {
|
|
578
|
+
return;
|
|
579
|
+
}
|
|
580
|
+
var shown = null;
|
|
581
|
+
chart.on("restore", function () {
|
|
582
|
+
shown = null;
|
|
583
|
+
});
|
|
584
|
+
chart.on("datazoom", function () {
|
|
585
|
+
var patch = reportZoomPatch(chart, option, reportZoomedAxes(chart));
|
|
586
|
+
var key = JSON.stringify(patch);
|
|
587
|
+
if (shown === null) {
|
|
588
|
+
shown = JSON.stringify(reportZoomPatch(chart, option, { xAxis: [], yAxis: [] }));
|
|
589
|
+
}
|
|
590
|
+
if (key !== shown) {
|
|
591
|
+
shown = key;
|
|
592
|
+
chart.setOption(patch);
|
|
593
|
+
}
|
|
594
|
+
});
|
|
595
|
+
}`;
|