// Data array for pageview
var data1 = [175482, 173921, 178700, 173445, 161303, 183206, 189261, 217394, 212578, 198895, 208623, 198026, 200070, 210005, 202120, 226972, 292047, 284975, 261037, 264295, 270422, 269353, 279135, 331320, 318608, 283991, 277259, 293945, 308135, 305437, 304406, 302415, 293567, 339569, 339286, 318603, 308628, 346517, 380255, 401014, 400551, 374231, 347277, 346659, 352628, 370844, 361397, 344931, 332978, 322979, 316816, 326260, 332066, 373403, 367229, 364258, 336124, 321106, 327089, 321979, 327933, 312738, 297174, 289470, 298910, 288113, 288649, 275576, 277637, 269326, 266297, 270346, 281770, 289829, 286486, 290191, 288483, 284481, 282943, 295527, 291992, 281244, 290836, 304520, 312638, 315248, 340015, 359397, 314658, 301604, 290045, 286285, 279677, 283368, 283455, 283472, 282046, 273739, 264889, 263804, 268360, 272038, 260891, 259681, 264792, 264437, 261575, 263431, 255635, 249191, 240464, 243134, 247868, 249436, 259109, 260240, 255172, 245218, 246684, 257279, 246445, 250681, 253160, 158083, 124375, 103424, 92013, 84288, 79570, 81353, 77501, 86423, 91367, 77134, 72733, 75086, 73187, 78561, 72893, 65001, 61389, 58644, 57300, 56425, 55216, 56025, 57242, 56695, 54606, 52382, 49065, 50394, 46373, 45043, 44081, 44282, 40008, 40695, 39078, 38132, 37556, 35148, 35020, 35007, 35611, 36426, 36385, 42478, 48364, 47425, 53957, 48190, 50320, 48604, 46921, 44851, 43966, 44070, 44526, 43346, 43620, 43827, 42943, 40981, 37430, 39619, 39029, 38970, 48079, 40831, 37650, 40742, 40700, 37518, 35734, 36837, 40780, 37878, 38511, 38254, 35875, 35839, 41012, 41748, 40820, 41776, 40940, 37594, 38706, 46713, 40631, 39482, 40146, 39345, 34579, 34940, 35261, 35055, 36278, 34577, 33946, 32180, 34504, 31709, 31277, 32966, 34396, 34261, 35065, 36156, 35215, 34973, 36506, 40976, 41071, 35887, 38473, 38858, 37412, 40535, 44409, 44536, 41461, 41800, 40481, 39448, 39021, 41847, 43265, 37960, 37131, 38756, 40067, 39809, 41746, 44520, 45984, 45759, 44644, 48365, 45358, 45164, 44856, 41710, 43218, 44381, 44425, 41489, 41245, 41952, 39868, 37437, 37874, 38719, 38276, 40039, 40005, 37065, 36563, 42630, 37110, 37776, 39769, 39497, 36519, 35525, 35092, 36555, 39983, 41987, 43808, 36193, 36513, 38174, 39410, 38374, 36556, 38514, 35384, 34289, 34999, 33570, 32052, 32420, 32501, 33185, 32231, 31748, 32109, 34841, 31627, 30443, 30402, 30155];
// Data array for revenue
var data2 = [299442, 33180, 44164, 64320, 31188, 58728, 51170, 71110, 30904, 49890, 25060, 54592, 22534, 30910, 33200, 45380, 213470, 66480, 46698, 27956, 28510, 26698, 35240, 49826, 21032, 20684, 23058, 517844, 38820, 36968, 55738, 30792, 56606, 95368, 114406, 34798, 40270, 64806, 40984, 648874, 51596, 29918, 16188, 23722, 47734, 126518, 12404, 45352, 17304, 9216, 15720, 8050, 11972, 60074, 35944, 40022, 13448, 9750, 35652, 21612, 29616, 13816, 11736, 11358, 4496, 5008, 5320, 5164, 15472, 5052, 8838, 8098, 12758, 16916, 13324, 7406, 5320, 7150, 5096, 8826, 5830, 7562, 4886, 10584, 7030, 23480, 30198, 138520, 59914, 19928, 12696, 4886, 5396, 11786, 21128, 7054, 5818, 3986, 4764, 3366, 31038, 14782, 16628, 26604, 6150, 5606, 6096, 3298, 4062, 6750, 20108, 3952, 12722, 14540, 15840, 10362, 8848, 11416, 13842, 28736, 49166, 86948, 1565909, 900688, 557794, 339925, 664926, 473350, 689774, 402080, 420521, 638988, 392180, 431914, 269295, 261676, 270954, 339928, 275089, 253029, 247369, 234981, 232589, 244266, 244664, 233087, 224729, 217735, 168010, 146194, 152023, 153050, 142455, 168606, 140659, 143223, 239705, 128025, 121093, 128441, 127542, 118867, 115868, 119637, 128197, 123581, 129278, 132579, 125553, 110726, 111422, 127128, 121054, 119403, 112723, 111009, 111474, 119426, 113466, 114289, 322513, 115420, 106960, 105607, 112066, 108237, 113590, 106305, 109339, 137888, 103884, 107584, 106967, 111812, 100912, 119070, 148792, 104320, 131466, 108102, 99345, 108561, 109215, 97207, 92543, 87652, 94948, 109616, 109156, 133712, 148817, 135683, 147067, 130922, 129803, 123451, 137160, 135665, 140403, 134741, 138206, 143147, 148932, 155647, 152880, 158969, 451934, 164884, 170810, 160699, 151346, 167893, 155146, 154829, 151858, 165947, 116710, 187580, 156930, 153688, 159757, 166433, 158303, 146643, 142649, 155342, 146755, 141523, 174641, 151867, 142453, 146778, 134649, 141274, 153333, 168872, 175895, 199033, 190424, 218914, 165567, 155901, 144086, 136720, 174984, 171623, 144970, 146119, 145935, 157678, 128397, 148313, 147427, 136660, 138163, 183704, 137265, 143517, 111793, 163393, 114919, 147670, 111951, 125935, 136032, 114382, 123258, 123734, 140712, 120323, 147892, 121365, 123875, 107051, 127847, 100241, 93117, 97354, 77423, 90725, 82374, 89811, 72655, 91521, 87517, 84807, 90336, 80807, 86127, 101905, 87863, 84640, 73935, 77973];
var x = d3.scale.linear().domain([0, data1.length]).range([0, w]);
var xlabel = d3.time.scale()
.domain([new Date(new Date("2012-03-01")), d3.time.day.offset(new Date("2013-01-08"), 1)])
.range([0, w]);
var y1 = d3.scale.linear().domain([0, data1.max()]).range([h, 0]);
var y2 = d3.scale.linear().domain([0, data2.max()]).range([h, 0]);
var line1 = d3.svg.line()
.x(function(d,i) {
console.log('Plotting X1 value for data point: ' + d + ' using index: ' + i + ' to be at: ' + x(i) + ' using our xScale.');
return x(i);
})
.y(function(d) {
console.log('Plotting Y1 value for data point: ' + d + ' to be at: ' + y1(d) + " using our y1Scale.");
return y1(d);
})
var line2 = d3.svg.line()
.x(function(d,i) {
console.log('Plotting X2 value for data point: ' + d + ' using index: ' + i + ' to be at: ' + x(i) + ' using our xScale.');
return x(i);
})
.y(function(d) {
console.log('Plotting Y2 value for data point: ' + d + ' to be at: ' + y2(d) + " using our y2Scale.");
return y2(d);
})
var revenue_pageview = d3.select("#revenue_pageview").append("svg:svg")
.attr("width", w + m[1] + m[3])
.attr("height", h + m[0] + m[2])
.append("svg:g")
.attr("transform", "translate(" + m[3] + "," + m[0] + ")");
var xAxis = d3.svg.axis().scale(xlabel).tickSize(-h).tickSubdivide(true);
revenue_pageview.append("svg:g")
.attr("class", "x axis")
.attr("transform", "translate(0," + h + ")")
.call(xAxis);
revenue_pageview.append("text")
.attr("class", "bottomlabel")
.attr("text-anchor", "end")
.attr("y", h + m[1]/2 +10)
.attr("x", w - 80)
.attr("dy", ".2em")
.text("Selected One Top Ranked Best Sell Fantasy Novel: King of Wisdom (奇幻玄幻: 圣王)");
revenue_pageview.append("text")
.attr("class", "bottomlabelauthor")
.attr("text-anchor", "end")
.attr("y", h + m[1]/2 + 30)
.attr("x", w - 60)
.attr("dy", ".2em")
.text("Wrote by millionaire author: Zhong Wang (王钟) Pen name: Meng Ru Shen Ji (梦入神机)")
var yAxisLeft = d3.svg.axis().scale(y1).ticks(4).orient("left");
revenue_pageview.append("svg:g")
.attr("class", "y axis axisLeft")
.attr("transform", "translate(-15,0)")
.call(yAxisLeft);
revenue_pageview.append("text")
.attr("class", "scaleleft")
.attr("text-anchor", "end")
.attr("y", 1)
.attr("dy", ".01em")
.attr("transform", "rotate(-90)")
.text("Pageviews");
var yAxisRight = d3.svg.axis().scale(y2).ticks(6).orient("right");
revenue_pageview.append("svg:g")
.attr("class", "y axis axisRight")
.attr("transform", "translate(" + (w+15) + ",0)")
.call(yAxisRight);
revenue_pageview.append("text")
.attr("class", "scaleright")
.attr("text-anchor", "end")
.attr("y", w)
.attr("dy", ".01em")
.attr("transform", "rotate(-90)")
.text("Revenue");
revenue_pageview.append("svg:path").attr("d", line1(data1)).attr("class", "data1");
revenue_pageview.append("svg:path").attr("d", line2(data2)).attr("class", "data2");