new GraphModel()
modules/tools/graph/model.js, line 19
Listens to Events:
Extends
Methods
-
appendDataToSvg(svg, data, className, d3line){Void}
modules/tools/graph/model.js, line 336 -
Creates the basic structure of a graph.
Name Type Description svgSVG The svg. dataArray.<Object> Data for graph. classNameString Class name of point. d3lineObject D3 line object. -
appendLegend(svg, legendData){Void}
modules/tools/graph/model.js, line 571 -
Creates a legend and adds it on the top left.
Name Type Description svgSVG SVG. legendDataArray.<Object> Legend object. Name Type Description styleString Type of legend item "rect" for " " or "circle" for " ". classString Class of legend item. textString Text of legend item. -
appendLinePointsToSvg(svg, data, scaleX, scaleY, xAttr, yAttrToShow, tooltipDiv, dotSize, setTooltipValue){Void}
modules/tools/graph/model.js, line 461 -
Appends line points to created line.
Name Type Description svgSVG Svg. dataArray.<Object> Data for graph. scaleXObject Scale for x-axis. scaleYObject Scale for y-axis. xAttrString Attribute name for x-axis. yAttrToShowString Attribute name for line point on y-axis. tooltipDivSelection Selection of the tooltip-div. dotSizeNumber The size of the dots. setTooltipValuefunction optional (optional) a function value:=function(value) to set/convert the tooltip value that is shown hovering a point - if not set or left undefined: default is >(...).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ".")< due to historic reasons -
appendXAxisToSvg(svg, xAxis, xAxisLabel, width, y){Void}
modules/tools/graph/model.js, line 375 -
Appends the x-axis to the svg.
Name Type Description svgSVG SVG. xAxisObject x-axis. xAxisLabelObject Definition of x-axis. Name Type Default Description labelString optional Text of label. offsetString 0 optional Offset between x-axis and text. textAnchorString middle optional Text anchor of x-axis label. fillString #000 optional Text fill color. fontSizeString 10 optional Text font size. widthNumber Width of SVG. yfunction y(value) transitions data value into pixel from top -
appendYAxisToSvg(svg, yAxis, yAxisLabel, height){Void}
modules/tools/graph/model.js, line 420 -
Appends the y-axis to the svg
Name Type Description svgSVG SVG. yAxisObject y-axis. yAxisLabelObject Definition of y-axis. Name Type Default Description labelString optional Text of label. offsetString 0 optional Offset between y-axis and text. textAnchorString middle optional Text anchor of y-axis label. fillString #000 optional Text fill color. fontSizeString 10 optional Text font size. heightNumber Height of SVG. -
createAxisBottom(scale, xAxisTicks){Object}
modules/tools/graph/model.js, line 255 -
Creates the bottom axis of the graph.
Name Type Description scaleObject Scale of bottom axis. xAxisTicksObject Ticks for bottom axis. Returns:
axisBottom
-
createAxisLeft(scale, yAxisTicks){Object}
modules/tools/graph/model.js, line 286 -
Creates the axis on the left.
Name Type Description scaleObject Scale of left axis. yAxisTicksObject Ticks for left axis. Returns:
axisLeft
-
createBarGraph(graphConfig){Void}
modules/tools/graph/model.js, line 790 -
Creates the BarGraph
Name Type Description graphConfigObject Graph config. Name Type Description selectorString Class for SVG to be appended to. scaleTypeXString Type of x-axis. scaleTypeYString Type of y-axis. dataArray.<Object> Data for graph. xAttrString Attribute name for x-axis. xAxisLabelObject Object to define the label for x-axis. Name Type Description labelString Label for x-axis. translateNumber Translation offset for label for x-axis. yAxisLabelObject Object to define the label for y-axis. Name Type Description labelString Label for y-axis. offsetNumber Offset for label for y-axis. attrToShowArrayArray.<String> Array of attribute names to be shown on y-axis. marginObject Margin object for graph. Name Type Description topNumber Top margin. rightNumber Right margin. bottomNumber Bottom margin. leftNumber left margin. widthNumber Width of SVG. heightNumber Height of SVG. xAxisTicksObject Ticks for x-axis. Name Type Description unitString Unit of x-axis-ticks. valuesArray.<Number/String> Values for x-axis-ticks. factorNumber Factor for x-axis-ticks. yAxisTicksObject Ticks for y-axis. Name Type Description ticksObject Values for y-axis-ticks. factorObject Factor for y-axis-ticks. svgClassString Class of SVG. legendDataArray.<Object> Data for legend. Name Type Description classString CSS class for legend object. textString Text for legend object. setTooltipValuefunction an optional function value:=function(value) to set/convert the tooltip value that is shown hovering a bar - if not set or left undefined: default is >(Math.round(d[attrToShowArray[0]] * 1000) / 10) + " %"< due to historic reasons -
createGraph(graphConfig){Void}
modules/tools/graph/model.js, line 55 -
Creates the graph. Distinguishes betweeen graphConfig.graphType === "Linegraph" and graphConfig.graphType === "BarGraph".
Name Type Description graphConfigObject Graph configuration. -
createLinearScale(minValue, maxValue, rangeArray){function}
modules/tools/graph/model.js, line 234 -
creates a linear d3 scale function
Name Type Description minValueNumber min value (from data) for the linear scale maxValueNumber max value (from data) for the linear scale rangeArrayArray.<Number> a simple array [maxPixel, minPixel] defining the diagrams range in pixel (e.g. [height, 0]) Returns:
a linear d3 scale function to translate values into pixel
-
createLineGraph(graphConfig){Void}
modules/tools/graph/model.js, line 667 -
Creates the Linegraph.
Name Type Description graphConfigObject Graph config. Name Type Description selectorString Class for SVG to be appended to. scaleTypeXString Type of x-axis. scaleTypeYString Type of y-axis. dataArray.<Object> Data for graph. xAttrString Attribute name for x-axis. xAxisLabelObject Object to define the label for x-axis. Name Type Description labelString Label for x-axis. translateNumber Translation offset for label for x-axis. yAxisLabelObject Object to define the label for y-axis. Name Type Description labelString Label for y-axis. offsetNumber Offset for label for y-axis. attrToShowArrayArray.<Object/String> Array of attribute names or objects to be shown on y-axis. Name Type Description attrNameArray.<Object/String> Name of attribute to be shown. attrClassArray.<Object/String> Class for line in graph. marginObject Margin object for graph. Name Type Description topNumber Top margin. rightNumber Right margin. bottomNumber Bottom margin. leftNumber left margin. widthNumber Width of SVG. heightNumber Height of SVG. xAxisTicksObject Ticks for x-axis. Name Type Description unitString Unit of x-axis-ticks. valuesArray.<Number/String> Values for x-axis-ticks. factorNumber Factor for x-axis-ticks. yAxisTicksObject Ticks for y-axis. Name Type Description ticksObject Values for y-axis-ticks. factorObject Factor for y-axis-ticks. svgClassString Class of SVG. selectorTooltipString Selector for tooltip div. legendDataArray.<Object> Data for legend. Name Type Description classString CSS class for legend object. textString Text for legend object. setTooltipValuefunction an optional function value:=function(value) to set/convert the tooltip value that is shown hovering a point - if not set or left undefined: default is >(...).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ".")< due to historic reasons -
createMaxValue(data, attrToShowArray){Number}
modules/tools/graph/model.js, line 94 -
searches for the maximum value overall values of data defined in attrToShowArray - note that this function is axis neutral
Name Type Description dataArray.<Object> the data for the graph - this is an array of objects for either Linegraph or BarGraph attrToShowArrayArray.<String> as defined in graphConfig - an array of keys to find the data for the axis in Returns:
the highest figure for any key in attrToShowArray found in data
-
createMinValue(data, attrToShowArray){Number}
modules/tools/graph/model.js, line 70 -
searches for the minimum value overall values of data defined in attrToShowArray - note that this function is axis neutral
Name Type Description dataArray.<Object> the data for the graph - this is an array of objects for either Linegraph or BarGraph attrToShowArrayArray.<String> as defined in graphConfig - an array of keys to find the data for the axis in Returns:
the lowest figure for any key in attrToShowArray found in data
-
createOrdinalScale(data, rangeArray, attrArray){function}
modules/tools/graph/model.js, line 199 -
creates an ordinal d3 scale function
Name Type Description dataArray.<Object> the data for the graph rangeArrayArray.<Number> a simple array [maxPixel, minPixel] defining the diagrams range in pixel (e.g. [height, 0]) attrArrayArray.<String> as defined in graphConfig.xAttr respectively graphConfig.attrToShowArray Returns:
a ordinal d3 scale function to translate values into pixel
-
createPeakValues(data, attrToShowArray, axisTicks){Object}
modules/tools/graph/model.js, line 119 -
gets an object with global the minimum and maximum values (peaks) of data defined in attrToShowArray - note that this function is axis neutral
Name Type Description dataArray.<Object> the data for the graph - this is an array of objects for either Linegraph or BarGraph attrToShowArrayArray.<String> as defined in graphConfig - an array of keys to find the data for the y axis in axisTicksObject optional (optional) as defined in graphConfig - used to force start and end of an axis when axisTicks.start and axisTicks.end is given. Otherwise automatic lookup of start and end point will be triggered. Returns:
an object {minValue, maxValue}
-
createScaleX(data, width, scaleTypeX, xAttr, xAxisTicks){function}
modules/tools/graph/model.js, line 143 -
creates a d3 scale for the x axis - in general a d3 scale is a function to translate a value into pixels to adjust dom objects in the diagram
Name Type Description dataArray.<Object> the data for the graph - this is an array of objects for either Linegraph or BarGraph widthNumber as defined in graphConfig - the width in pixel to draw the diagram in (note: a margin should be calculated out of width at this point already) scaleTypeXString as defined in graphConfig - should be "ordinal" or "linear" xAttrString as defined in graphConfig - the key for x-axis data to be found in data xAxisTicksObject optional (optional) as defined in graphConfig - if not given automatic processing will take place Returns:
a function "pixels := function(value)" to translate a value from data into pixels from left to right of the diagram
-
createScaleY(data, height, scaleTypeY, attrToShowArray, yAxisTicks){function}
modules/tools/graph/model.js, line 173 -
creates a d3 scale for the y axis - in general a d3 scale is a function to translate a value into pixels to adjust dom objects in the diagram
Name Type Description dataArray.<Object> the data for the graph - this is an array of objects for either Linegraph or BarGraph heightNumber as defined in graphConfig - the height in pixel to draw the diagram in (note: a margin should be calculated out of height at this point already) scaleTypeYString as defined in graphConfig - should be "ordinal" or "linear" attrToShowArrayArray.<String> as defined in graphConfig - an array of keys to find the data for the y axis in yAxisTicksObject optional (optional) as defined in graphConfig - if not given automatic processing will take place Returns:
a function "pixels := function(value)" to translate a value from data into pixels from top to bottom of the diagram
-
createSvg(selector, left, top, width, height, svgClass){SVG}
modules/tools/graph/model.js, line 552 -
Creates the SVG.
Name Type Description selectorString Class of DOM element where svg gets appended. leftNumber Left border of SVG. topNumber Right border of SVG. widthNumber Width of SVG. heightNumber Height of SVG. svgClassString Class of SVG. Returns:
SVG
-
createValueLine(scaleX, scaleY, xAttr, yAttrToShow){Object}
modules/tools/graph/model.js, line 315 -
Creates a d3 line object.
Name Type Description scaleXObject Scale of x-axis. scaleYObject Scale of y-axis. xAttrString Attribute name for x-axis. yAttrToShowstring Attribut name for y-axis. Returns:
valueLine.
-
drawBars(svg, dataToAdd, x, y, selector, xAttr, attrToShowArray, barWidth, setTooltipValue){Void}
modules/tools/graph/model.js, line 836 -
draws the bars into the svg using d3 functions
Name Type Description svgSVG the d3 svg object dataToAddArray.<Object> the data for the bar graph as an array of objects [{ (xAttr): valueX, (attrToShowArray[0]): valueY}, ...] where xAttr and attrToShowArray[0] are keys defined in graphConfig xfunction the function to give the place of data value looking from left to right in pixel yfunction y(value) transitions data value into pixel from top selectorString as set in graphConfig - may be css class of the dom holding the graph xAttrString as defined in graphConfig - the name of the key to address the valueX in dataToAdd attrToShowArrayArray.<String> as defined in graphConfig - the array of keys to find the data of valueY in dataToAdd barWidthNumber the width of a single bar - note that if zero or negative, barWidth will be automatically set to 0 setTooltipValuefunction optional (optional) a function value:=function(value) to set/convert the tooltip value that is shown hovering a bar - if not set or left undefined: default is >(Math.round(d[attrToShowArray[0]] * 1000) / 10) + " %"< due to historic reasons -
flattenAttrToShowArray(attrToShowArray){Array.<String>}
modules/tools/graph/model.js, line 613 -
Flattens the attributeToShowArray and only returns an array of the attrNames.
Name Type Description attrToShowArrayArray.<Object/String> Array of objects or strings. Returns:
Flattened Array.
-
rotateXAxisTexts(svg){Void}
modules/tools/graph/model.js, line 738 -
Rotates the label on the x-axis by 45 degrees
Name Type Description svgSVG SVG. -
setGraphParams(value){Void}
modules/tools/graph/model.js, line 900 -
Setter for attribute "graphParams".
Name Type Description valueObject Graph params. -
translateXAxislabelText(svg, xAxisLabelTranslate){Void}
modules/tools/graph/model.js, line 749 -
Moves the label of the x-axis downwards
Name Type Description svgSVG SVG. xAxisLabelTranslateNumber Translation on the x-axis.