HTMLcopy
1
<div id="container"></div>
CSScopy
6
1
html, body, #container {
2
width: 100%;
3
height: 100%;
4
margin: 0;
5
padding: 0;
6
}
JavaScriptcopy
x
1
anychart.onDocumentReady(function () {
2
3
var dataSet = anychart.data.set(getData());
4
var seriesData_1 = dataSet.mapAs({'x': 0, 'value': 1});
5
var seriesData_2 = dataSet.mapAs({'x': 0, 'value': 2});
6
7
var chart = anychart.line();
8
chart.animation(true);
9
chart.padding([10, 20, 5, 20]);
10
11
var series_1 = chart.line(seriesData_1);
12
var series_2 = chart.line(seriesData_2);
13
14
series_1.name("Before May 22");
15
series_2.name("After May 22");
16
17
18
// turn the legend on
19
chart.legend()
20
.enabled(true)
21
.fontSize(13)
22
.padding([0, 0, 10, 0]);
23
24
// set container id for the chart
25
chart.container('container');
26
// initiate chart drawing
27
chart.draw();
28
});
29
30
function getData() {
31
//const improvedData = '4515,3532,2954,3815,3325,3581,3289,2970,2494,3654,2903,3456,3928,3768,3344,2534,3723,4086,3221,3186,3684,3353,3181,3113,2699,2874,2619,3110,4122,3127,2920,3303,3385,3639,3841,3242,2890,3272,3098,2960,2969,2992,2795,2737,4525,3365,3563,3491,2856,3072,3161,3259,2939,2813,3798,2713,2806,2951,4039,3602,3690,3100,3754,6885,3600,3362,3184,4697,3597,4621,4265,3391,2857,3240,2816,4091,3799,2787,3628,3895,3505,3314,3256,2939,3378,3288,4160,2953,4175,2879,5015,3721,3423,3957,3933,3074,3473,3714,3076,3195,4218,2678,3826,4217,3682,5859,3426,2903,3765,4261,4138,3708,2905,4773,3857,3844,3126,3591,3417,2468,2677,3687,4476,4053,3589,2966,3013,3656,5119,3946,2984,2493,3073,3024,3516,2924,2815,2872,2469,3544,2638,3067,3734,3302,2943,3302,2851,3628,4274,3413,3599,6076,7032,3118,3019,3768,4043,4652,4608,3655,3116,3172,3151,4769,2882,3460,3591,3837,4009,3023,2708,2459,3322,4305,4179,4233,4120,3320,3169,2451,3613,3510,3767,3512,5130,2917,3101,3128,2670,4364,2509,3347,4006,2833,2747,4032,4030,4395,3476,5070,3698,3667,3924,4352,3813,3398,3951,3684,3761,3955,3166,2932,2845,4126,3172,3164,2652,3676,3821,4263,3231,2837,3353,3021,3612,3970,3029,3110,3096,3310,3687,2947,3870,3177,2990,2643,3436,3777,3798,3135,3035,2479,2680,3366,2870,4019,3311,3102,3138,2485,4395,2929,3756,2833,3695,2934,2937,3867,2896,3132,2847,3714,4202,2337,3590,4372,3409,3001,3019,2634,3151,2795,3384,2625,2850,3608,3651,3103,3327,2639,2817,4174,3536,3416,2990,3019,2793,3367,3453,3351,3264,3622,2932,3794,3236,3464,2869,3150,3167,3329,3795,3250,2991,3047,3352,3605,2754,2980,2966,3907,3292,3209,3656,3290,3749,2895,2849,3891,4209,4157,2877,3387,3226,3079,3322,2889,3823,2569,3212,2890,2718,4126,3085,2756,3160,2970,3144,2731,2545,2831,2762,3667,4411,2925,2566,2924,2616,3434,2861,3165,3452'
32
const before = [8153,6858,6247,8775,6384,6157,6480,5599,6883,6837,5615,5801,7067,6766,6613,8251,9617,6338,6718,5716,7005,6480,6378,6813,6066,6322,6615,6885,5975,6631,7420,6014,6572,5755,6632,6971,8362,7189,8031,5847,6380,5884,6398,6525,6504,6183,6277,7060,6687,5552,7560,8074,6715,6540,6406,6974,5810,5399,6152,7289,7362,7770,8883,6924,6073,6741,6665,6814,8120,7171,6469,6661,6397,8168,9319,6291,6717,7766,5803,7135,6387,5980,7038,6904,6414,5748,6070,7574,7490,6941,5925,6129,6939,8031,7025,6173,6712,8988,6884,5845,5528,6295,5912,5347,8606,6592,6608,7065,6874,5988,7663,7562,6391,6445,7382,6074,6743,6116,6436,6065,7252,6142,5698,6765,5698,6403,7531,7054,6958,6188,8966,7597,7401,8018,7514,6403,6658,6462,6318,6185,6501,6864,7074,6044,6052,6440,6041,6698,7500,6557,6842,6984,6849,6113,8327,6833,8397,7638,7625,6431,7815,7217,7394,7012,7938,8757,8432,6848,7119,7249,6717,6728,6776,7889,8717,8160,7309,8393,7630,9630,9355,8111,8330,7490,8263,6491,6962,7828,7150,7759,6316,6543,6053,6202,6273,7082,7646,8476,8528,7074,7358,6802,7457,6459,6796,8178,7219,7429,6454,7484,8477,8045,8451,7437,8399,7566,8745,6690,7865,6656,6868,7680,6951,6019,6184,6810,8053,9428,8193,6085,6042,7285,6551,7250,7363,7135,8383,7596,7557,6807,6579,7574,6407,5601,7306,5839,6453,7064,6664,7167,7153,7018,6957,6928,6799,8769,7583,6930,5473,5549,6088,7463,7890,6806,7067,7729,9990,7407,7168,8233,7184,6811,7044,7584,7491,6810,8231,8456,8366,6878,7247,6837,7957,8308,6564,6292,6573,7160,6861,7850,7291,6827,7374,6919,7272,8061,9620,7689,8300,7273,6170,7392,8957,9677,7259,6520,6612,6754,6759,6745,6534,6458,7148,8147,6404,5558,6703,6876,6631,7019,7805,7795,5896,6306,8596,7975,7141,6414,7350,6488,7337,6824,7260,7171,7616,6611,5740,8047,6917,6789,7486,8121,6762,6890,6547,8327,7255,6211,8970,5880,6830]
33
const liveData = [8652,5403,5888,5486,6447,6409,6685,6049,5714,6289,6449,5636,8077,6255,8921,6831,7114,9585,8497,6315,5491,6522,5383,5828,5975,6448,6523,7590,6315,5944,6318,5619,6277,7116,7189,7048,5411,7097,6031,5229,5807,5650,5597,6227,7205,6343,7876,6060,6305,6164,5216,6339,6270,6494,6416,5753,5647,7124,5577,5742,7270,5967,5686,4791,6144,5767,7699,6500,5828,5887,6626,6746,6735,6362,6047,7253,6090,6634,7188,6570,6753,6878,5585,5816,7119,5332,5948,7161,8793,5968,6921,7326,6954,6245,4839,5331,5459,6224,6075,6125,6377,7800,5705,6377,5647,7334,7559,6236,7390,7235,6904,6979,6680,6785,6905,7735,6131,6471,7169,6192,7298,6111,5008,5691,5288,7198,6344,8038,6828,7648,6747,7144,6709,6164,7405,7450,6368,7036,8139,5817,5789,6434,6168,5807,6325,6583,5551,5791,6604,7421,8116,6967,6343,7375,8977,7283,8307,7220,8672,8335,6317,6440,7368,5943,7134,9410,7549,7910,8643,6901,7940,7805,6792,8865,6814,7358,8317,7344,7582,6556,5771,9268,7473,6285,7492,9168,8795,9091,9143,8801,9291,8076,8082,7148,8117,7751,6294,6426,6110,7244,5974,7377,8577,6587,7569,8447,7515,6370,7156,6828,6041,5637,6488,6151,5662,5639,6827,5967,5845,7536,6649,6448,6426,5791,5353,8395,6147,5837,6862,6586,6467,6904,6740,6962,6853,7393,6390,7032,5550,5838,6773,6508,5881,6254,7898,8644,5708,6171,6056,7383,6208,7159,6781,5171,5995,6763,5932,7078,6607,6677,6557,6218,6385,6094,5665,5508,7263,6360,6108,5792,6521,6198,7526,6276,6522,9264,6901,6361,7103,6144,7270,7749,6687,6303,7807,7424,6793,6057,6735,6498,5826,6192,7757,6389,5615,6783,6612,7276,7173,6929,5610,6159,6433,6334,6251,6078,5713,5892,6018,5932,6645,5632,6540,5631,5544,5611,6888,8401,6393,6341,8466,6504,6637,6847,6000,5632,5993,6266,6630,6274,6889,6213,6635,5663,5999,6199,6800,7989,5111,6634,6683,6543,6283,6182,6407,5617,7134,5952,6770,7495,6757]
34
35
return before
36
.map((value, index) => [String(index), value, liveData[index]])
37
38
return [
39
['Jan', 35.3],
40
['Feb', 21.9],
41
['Mar', 25.4],
42
['Apr', 16.4],
43
['May', 19.1],
44
['Jun', 18.4],
45
['Jul', 24.2],
46
['Aug', 18.5],
47
['Sep', 16.2],
48
['Oct', 14.3],
49
['Nov', 15.8],
50
['Dec', 13.3],
51
]
52
}