forked from NorthwoodsSoftware/GoJS
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcandlestickCharts.html
More file actions
74 lines (69 loc) · 2.85 KB
/
Copy pathcandlestickCharts.html
File metadata and controls
74 lines (69 loc) · 2.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Candlestick or Range Charts</title>
<meta name="description" content="GoJS nodes containing simple range charts." />
<!-- Copyright 1998-2017 by Northwoods Software Corporation. -->
<meta charset="UTF-8">
<script src="../release/go.js"></script>
<script src="../assets/js/goSamples.js"></script> <!-- this is only for the GoJS Samples framework -->
<script id="code">
function init() {
if (window.goSamples) goSamples(); // init for these samples -- you don't need to call this
var $ = go.GraphObject.make; // for conciseness in defining templates
myDiagram =
$(go.Diagram, "myDiagramDiv", // must name or refer to the DIV HTML element
{ initialContentAlignment: go.Spot.Center });
// the template for each attribute in a node's array of item data
var itemTempl =
$(go.Panel, "TableRow",
$(go.TextBlock,
{ column: 0 },
new go.Binding("text")),
$(go.Shape,
{ column: 1, alignment: go.Spot.Left },
{ fill: "slateblue", stroke: "darkblue" },
new go.Binding("geometry", "", produceRange)));
function produceRange(d) {
var h = 12; // total height for the markers
var w = 3; // half width for the median marker
// using constructors is more efficient than calling go.GraphObject.make:
return new go.Geometry()
.add(new go.PathFigure(d.min, h / 2, false)
.add(new go.PathSegment(go.PathSegment.Line, d.max, h / 2)))
.add(new go.PathFigure(d.min, 0, false)
.add(new go.PathSegment(go.PathSegment.Line, d.min, h)))
.add(new go.PathFigure(d.max, 0, false)
.add(new go.PathSegment(go.PathSegment.Line, d.max, h)))
.add(new go.PathFigure(d.val-w, 0)
.add(new go.PathSegment(go.PathSegment.Line, d.val+w, 0))
.add(new go.PathSegment(go.PathSegment.Line, d.val + w, h))
.add(new go.PathSegment(go.PathSegment.Line, d.val - w, h).close()));
}
myDiagram.nodeTemplate =
$(go.Node, "Auto",
$(go.Shape,
{ fill: "white" }),
$(go.Panel, "Table",
{ margin: 6,
itemTemplate: itemTempl },
new go.Binding("itemArray", "items")));
var nodeDataArray = [
{
items: [ { text: "first", min: 10, val: 50, max: 60 },
{ text: "second", min: 20, val: 70, max: 90 },
{ text: "third", min: 40, val: 60, max: 110 },
{ text: "fourth", min: 50, val: 80, max: 130 } ]
}
];
myDiagram.model = new go.GraphLinksModel(nodeDataArray);
}
</script>
</head>
<body onload="init()">
<div id="sample">
<div id="myDiagramDiv" style="background-color: white; border: solid 1px black; width: 100%; height: 500px"></div>
</div>
</body>
</html>