/* This maps an index to a value that it represents in the graph range */
tickLabelValueScale = PV.Scale.linear(0, totalBarWidth).range(
barScaleStart, barScaleEnd);
/* A scale that maps 0 - 1000 to 50 - 1050 */
PVLinearScale tickPositionScale = PV.Scale.linear(0, totalBarWidth)
.range(LEFT_LABEL_PADDING, totalBarWidth + LEFT_LABEL_PADDING);
/* Root panel */
PVPanel vis = chartWidget
.getPVPanel()
.width(totalBarWidth + LEFT_LABEL_PADDING + CHART_RIGHT_PADDING)
.height(chartHeight + CHART_BOTTOM_PADDING);
/* Add one panel for each horizontal bar */
PVPanel panel = vis.add(PV.Panel).data(dataPairs).top(panelTopFunction)
.height(panelHeightFunction);
/* an invisible panel that will handle mouse events */
invisibleInteractionBar = vis.add(PV.Panel).data(visualItemsJsArray)
.left(LEFT_LABEL_PADDING).width(totalBarWidthFunction)
.top(panelTopFunction).height(panelHeightFunction)
.cursor(POINTER).events(ALL)
.strokeStyle(barBorderColorFunction).lineWidth(3);
/* Add a label to each panel */
panel.anchor(PVAlignment.LEFT).add(PV.Label).text(panelLabelFunction);
PVPanel innerPanel = panel.add(PV.Panel).left(LEFT_LABEL_PADDING)
.fillStyle("#ffffff");
/* Add many vertical bars (slices) to each horizontal Panel (bar) */
innerPanel.add(PV.Bar).data(childDataFunction).top(0)
.left(sliceLeftFunction).width(sliceWidthFunction)
.fillStyle(colorFunction);
/* Add X axis ticks with number labels */
vis.add(PV.Rule).data(tickPositionScale.ticks(calculateNumTicks()))
.left(tickPositionScale).bottom(CHART_BOTTOM_PADDING).height(5)
.strokeStyle("#000").anchor(PVAlignment.BOTTOM).add(PV.Label)
.text(tickLabelFunction);
}