diff --git a/src/ts/main.ts b/src/ts/main.ts index 52e04aba..ff5cef8a 100755 --- a/src/ts/main.ts +++ b/src/ts/main.ts @@ -2,7 +2,7 @@ import {createWaterfallSvg} from "./waterfall/svg-chart" import {Har} from "./typing/har.d" import * as dom from "./helpers/dom" import HarTransformer from "./transformers/har" - +import {ChartOptions} from "./typing/options.d" function showErrorMsg(msg) { alert(msg) @@ -13,7 +13,10 @@ const outputHolder = document.getElementById("output") function renderHar(logData: Har) { const data = HarTransformer.transfrom(logData) dom.removeAllChildren(outputHolder) - outputHolder.appendChild(createWaterfallSvg(data, 23)) + let options = { + rowHeight: 23 + } as ChartOptions + outputHolder.appendChild(createWaterfallSvg(data, options)) } function onFileSubmit(evt) { diff --git a/src/ts/typing/options.d.ts b/src/ts/typing/options.d.ts new file mode 100644 index 00000000..2b09ad69 --- /dev/null +++ b/src/ts/typing/options.d.ts @@ -0,0 +1,4 @@ +export interface ChartOptions { + /** Height of every request bar block plus spacer pixel (in px) */ + rowHeight: number +} diff --git a/src/ts/waterfall/svg-chart.ts b/src/ts/waterfall/svg-chart.ts index aa6f2f23..15fdfec6 100644 --- a/src/ts/waterfall/svg-chart.ts +++ b/src/ts/waterfall/svg-chart.ts @@ -1,5 +1,6 @@ import {WaterfallData} from "../typing/waterfall-data.d" import {RectData} from "../typing/rect-data.d" +import {ChartOptions} from "../typing/options.d" import TimeBlock from "../typing/time-block" import * as svg from "../helpers/svg" import { @@ -33,12 +34,11 @@ function getSvgHeight(marks: any[], barsToShow: TimeBlock[], diagramHeight: numb /** * Entry point to start rendering the full waterfall SVG * @param {WaterfallData} data Object containing the setup parameter - - * @param {requestBarHeight} number Height of every request bar block plus spacer pixel + * @param {options} ChartOptions Config options * @return {SVGSVGElement} SVG Element ready to render */ -export function createWaterfallSvg(data: WaterfallData, requestBarHeight: number = 23): SVGSVGElement { - +export function createWaterfallSvg(data: WaterfallData, options: ChartOptions): SVGSVGElement { + let requestBarHeight = options.rowHeight //constants /** Width of bar on left in percentage */