Skip to content

Commit

Permalink
#33 add option object
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Mrowetz committed May 11, 2016
1 parent f9c893f commit a1d3fc1
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
7 changes: 5 additions & 2 deletions src/ts/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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) {
Expand Down
4 changes: 4 additions & 0 deletions src/ts/typing/options.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export interface ChartOptions {
/** Height of every request bar block plus spacer pixel (in px) */
rowHeight: number
}
8 changes: 4 additions & 4 deletions src/ts/waterfall/svg-chart.ts
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down Expand Up @@ -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 */
Expand Down

0 comments on commit a1d3fc1

Please sign in to comment.