Skip to content

Commit f067761

Browse files
committed
Update basic/line.md
1 parent 5f2b444 commit f067761

File tree

1 file changed

+34
-48
lines changed

1 file changed

+34
-48
lines changed

basic/line.md

Lines changed: 34 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,60 +1,51 @@
1-
Let's create a simple line chart. For example, count of entities that were completed by month.
1+
Let's create a simple line chart. For example, let's plot *sin()* and *cos()* functions on one chart.
22

33
Here is our datasource:
44

55
```javascript
6-
var defData = [{
7-
type:'us', count:0, date:'12-2013'
8-
},{
9-
type:'us', count:10, date:'01-2014'
10-
},{
11-
type:'us', count:15, date:'02-2014'
12-
},
13-
...
14-
{
15-
type:'bug', count:23, date:'05-2014'
16-
}];
6+
function data() {
7+
return (_
8+
.times(100, function (i) {return i;})
9+
.reduce(function (memo, x) {
10+
var i = x / 100;
11+
return memo.concat([
12+
{type: 'sin', i: i, val: Math.sin(i)},
13+
{type: 'cos', i: i, val: Math.cos(i)}
14+
]);
15+
}, []));
16+
}
1717
```
1818

19-
Red line shows bugs and blue line shows user stories. Colors coding is defined in *guide* property.
19+
Let's take red line shows *sin()* and green shows *cos()*. Colors brewer is defined in *guide.color.brewer* property.
2020

2121
```javascript
22-
var chart = new tauCharts.Chart({
22+
new tauCharts.Chart({
23+
data: data(),
24+
type: 'line',
25+
x: 'i',
26+
y: 'val',
27+
color: 'type',
2328
guide: {
24-
padding: {l: 70, t: 10, b: 70, r: 10},
25-
showGridLines: 'xy',
26-
color: {
27-
brewer: { // set color for every 'type' in datasource
28-
us: 'color-us',
29-
bug: 'color-bug'
30-
}
31-
},
32-
y: {
33-
label: {
34-
text: 'Count of completed entities',
35-
padding: 50
36-
}
37-
},
38-
x: {
39-
label: 'Month'
29+
color: {
30+
brewer: { sin: '#ff0000', cos: '#00ff00' }
4031
}
41-
},
42-
data: defData,
43-
type: 'line',
44-
x: 'date',
45-
y: 'count',
46-
color: 'type' // we have two types in datasource, so there will be two lines on the chart
47-
});
32+
}
33+
}).renderTo('#target');
34+
```
4835

49-
chart.renderTo('#line');
36+
See [guide](guide.md) reference for another sophisticated settings.
5037

51-
```
38+
[Example](http://jsfiddle.net/taucharts/4vgoddao/)
39+
40+
#### split
41+
By default data chunks for a line chart are split by color parameter. Taucharts gives the **split** parameter as an additional way to split data for lines. It is useful when you need to draw separate lines per *property A* and colorize them (optionally) by another *property B*.
5242

53-
Use [guide](guide.md) property for visual settings.
43+
Here is an example:
5444

55-
[example jsFiddle](http://jsfiddle.net/taucharts/4o4z6fqn/)
45+
[Example](http://jsfiddle.net/oqyu0j2n/)
5646

57-
Let's consider more complex example of line chart.
47+
#### size
48+
Taucharts allows lines of variable width.
5849

5950
Minard's ["Figurative map of the successive losses of men in the French army during the Russian campaign, 1812-1813"](https://en.wikipedia.org/wiki/Charles_Joseph_Minard) is now one of the most famous statistical graphics, thanks to Tufte. Example below demonstrates how to build it using Taucharts:
6051

@@ -72,9 +63,4 @@ new tauCharts.Chart({
7263
```
7364
[Example](http://jsfiddle.net/0bu5oo8b/)
7465

75-
#### split
76-
By default data chunks for a line chart are split by color parameter. Taucharts gives the **split** parameter as an additional way to split data for lines. It is useful when you need to draw separate lines per *property A* and colorize them (optionally) by another *property B*.
77-
78-
Here is an example:
79-
80-
[Example](http://jsfiddle.net/oqyu0j2n/)
66+
See [size encoding](advanced/) for detailed reference.

0 commit comments

Comments
 (0)