我想计算时间数s1,s2,s0来自JSON.with信息日期(日期路径如下,review_details>> JSON的变量vf)在X轴上与否。的评论(s1 / s0 / s2计数)在Y轴上。 它应该是多线图表(s1,s2,s0线,颜色不同) 我被困在代码中间。不能计算s1,s2,s0的计数,并将其解析为y轴域以绘制它。
var JSON = {"restaurant_code": {"rp": "rest city", "rd": "rest link", "re": "rest rating", "rf": "rest cost", "rg": "rest cuisine", "ra": "rest known for", "rb": "rest location", "rc": "rest votes", "rl": "rest long", "rm": "rest lat", "rn": "rest map link", "ro": "rest locality", "rh": "rest type", "ri": "rest order", "rj": "rest name", "rk": "rest collection"}, "restaurant_type_code": {"rt_6": "lounge", "rt_5": "na", "rt_4": "quick bites", "rt_3": "dessert parlor", "rt_2": "casual dining", "rt_1": "fine dining"}, "review_code": {"va": "restaurant ref id", "vb": "user id", "vc": "review device", "vd": "review", "ve": "user rating", "vf": "review time", "vg": "keywords", "vh": "scrape time", "vi": "topics", "vj": "date category", "vk": "sentiment"}, "user_detail": [{"uf": "F", "ue": "https://www.zomato.com/GluttonIsAThing", "ud": "GluttonIsAThing", "ua": "Kanika Bhatia", "uc": "NA", "ub": "NA"}, {"uf": "M", "ue": "https://www.zomato.com/PureVegPunjabi", "ud": "PureVegPunjabi", "ua": "Abhinav Sobti", "uc": 212, "ub": 6}, {"uf": "M", "ue": "https://www.zomato.com/users/kanishq-sharma-3393281", "ud": "kanishq-sharma-3393281", "ua": "Kanishq Sharma", "uc": 46, "ub": 71}, {"uf": "F", "ue": "https://www.zomato.com/zainab606", "ud": "zainab606", "ua": "Zainab Feroz", "uc": 76, "ub": 124}, {"uf": "F", "ue": "https://www.zomato.com/tspshikari", "ud": "tspshikari", "ua": "Tspshikari", "uc": 19, "ub": 25}, {"uf": "M", "ue": "https://www.zomato.com/pongo", "ud": "pongo", "ua": "AJAI ATAL", "uc": 2767, "ub": 259}, {"uf": "M", "ue": "https://www.zomato.com/users/kanishq-sharma-3393281", "ud": "kanishq-sharma-3393281", "ua": "Kanishq Sharma", "uc": 46, "ub": 71}, {"uf": "M", "ue": "https://www.zomato.com/users/manish-dhankher-1163412", "ud": "manish-dhankher-1163412", "ua": "Manish Dhankher", "uc": 7, "ub": 3}, {"uf": "M", "ue": "https://www.zomato.com/users/anurag-singh-8819021", "ud": "anurag-singh-8819021", "ua": "Anurag Singh", "uc": 1, "ub": 1}, {"uf": "F", "ue": "https://www.zomato.com/users/aye-erginbas-payal-11818251", "ud": "aye-erginbas-payal-11818251", "ua": "Ay\u015fe Erginbas Payal", "uc": 1, "ub": 1}], "topic_code": {"tp": "washrooms", "tn": "service", "to": "taste/quality", "tl": "pricing", "tm": "quantity", "tj": "music", "tk": "presentation", "th": "location", "ti": "menu", "tf": "hygiene", "tg": "infra/services", "td": "experience", "te": "food", "tb": "decor", "tc": "drinks", "ta": "ambience"}, "cuisine_code": {"cu_14": "italian", "cu_16": "finger food", "cu_10": "bakery", "cu_13": "fast food", "cu_4": "north indian", "cu_7": "street food", "cu_1": "chinese", "cu_2": "continental", "cu_9": "south indian"}, "review_detail": [{"va": 1, "vb": "GluttonIsAThing", "vc": "iOS", "ve": 2.5, "vf": "2014-12-19 02:22:31", "vg": ["demise", "eyes"], "vk": "s1", "_id": "55c3230b34876e33212244cf", "vj": ["m6"]}, {"va": 1, "vb": "GluttonIsAThing", "vc": "iOS", "ve": 2.5, "vf": "2014-12-19 02:22:31", "vg": [], "vk": "s1", "_id": "55c3230b34876e33212244d0", "vj": ["m6"]}, {"va": 1, "vb": "GluttonIsAThing", "vc": "iOS", "ve": 2.5, "vf": "2014-12-19 02:22:31", "vg": ["first visit", "head", "heels", "love", "visit yesterday"], "vk": "s1", "_id": "55c3230b34876e33212244d1", "vj": ["m6"]}, {"va": 1, "vb": "GluttonIsAThing", "vc": "iOS", "ve": 2.5, "vf": "2014-12-19 02:22:31", "vg": ["you order biryani", "rice stale", "meat"], "vj": ["m6"], "vk": "s0", "_id": "55c3230b34876e33212244d2"}, {"va": 1, "vb": "GluttonIsAThing", "_id": "55c3230b34876e33212244d3", "ve": 2.5, "vf": "2014-12-19 02:22:31", "vg": ["time", "su mai", "dimsums", "fish", "mustard", "pad thai"], "vj": ["m6"], "vk": "s0", "vc": "iOS"}, {"va": 1, "vb": "GluttonIsAThing", "vc": "iOS", "ve": 2.5, "vf": "2014-12-19 02:22:31", "vg": ["dimsums"], "vk": "s1", "_id": "55c3230b34876e33212244d4", "vj": ["m6"]}, {"va": 1, "vb": "GluttonIsAThing", "vc": "iOS", "ve": 2.5, "vf": "2014-12-19 02:22:31", "vg": ["high recommendation", "return", "thumbs"], "vj": ["m6"], "vk": "s2", "_id": "55c3230b34876e33212244d5"}, {"va": 1, "vb": "GluttonIsAThing", "vc": "iOS", "ve": 2.5, "vf": "2014-12-19 02:22:31", "vg": ["worst part", "arrogance", "chef", "feedback", "pad thai"], "vj": ["m6"], "vk": "s2", "_id": "55c3230b34876e33212244d6"}, {"va": 3, "vb": "PureVegPunjabi", "vc": "NA", "ve": 3.5, "vf": "2015-05-03 12:10:32", "vg": ["family", "rating", "reviews", "zomato"], "vj": ["m6"], "vk": "s0", "_id": "55c3254f34876e33212244d7"}, {"va": 3, "vb": "PureVegPunjabi", "vc": "NA", "ve": 3.5, "vf": "2015-05-03 12:10:32", "vg": ["wrong restaurant", "sweet shop"], "vj": ["m6"], "vk": "s0", "_id": "55c3254f34876e33212244d8"}, {"va": 3, "vb": "PureVegPunjabi", "vc": "NA", "ve": 3.5, "vf": "2015-05-03 12:10:32", "vg": ["surprise", "only people", "restaurant", "time", "2:30 pm", "saturday"], "vk": "s1", "_id": "55c3254f34876e33212244d9", "vj": ["m6"]}, {"va": 3, "vb": "PureVegPunjabi", "vc": "NA", "ve": 3.5, "vf": "2015-05-03 12:10:32", "vg": ["service", "improvement", "35 minutes", "food", "table"], "vj": ["m6"], "vk": "s0", "_id": "55c3254f34876e33212244da"}, {"va": 3, "vb": "PureVegPunjabi", "vc": "NA", "ve": 3.5, "vf": "2015-05-03 12:10:32", "vg": ["acs"], "vj": ["m6"], "vk": "s2", "_id": "55c3254f34876e33212244db"}, {"va": 3, "vb": "PureVegPunjabi", "_id": "55c3254f34876e33212244dc", "ve": 3.5, "vf": "2015-05-03 12:10:32", "vg": ["dal agrabana malai kofta veg biryani mix veg raita", "breads"], "vj": ["m6"], "vk": "s0", "vc": "NA"}, {"va": 3, "vb": "PureVegPunjabi", "vc": "NA", "ve": 3.5, "vf": "2015-05-03 12:10:32", "vg": ["recommend malai kofta"], "vk": "s1", "_id": "55c3254f34876e33212244dd", "vj": ["m6"]}, {"va": 3, "vb": "PureVegPunjabi", "vc": "NA", "ve": 3.5, "vf": "2015-05-03 12:10:32", "vg": ["biryani", "special flavour"], "vk": "s1", "_id": "55c3254f34876e33212244de", "vj": ["m6"]}, {"va": 3, "vb": "PureVegPunjabi", "vc": "NA", "ve": 3.5, "vf": "2015-05-03 12:10:32", "vg": ["dal agrabana", "makhani"], "vj": ["m6"], "vk": "s0", "_id": "55c3254f34876e33212244df"}, {"va": 3, "vb": "PureVegPunjabi", "_id": "55c3254f34876e33212244e0", "ve": 3.5, "vf": "2015-05-03 12:10:32", "vg": ["food", "nearby options"], "vk": "s1", "vc": "NA", "vj": ["m6"]}, {"va": 3, "vb": "PureVegPunjabi", "vc": "NA", "ve": 3.5, "vf": "2015-05-03 12:10:32", "vg": ["budget family meal"], "vk": "s1", "_id": "55c3254f34876e33212244e1", "vj": ["m6"]}, {"va": 4, "vb": "kanishq-sharma-3393281", "_id": "55c3256534876e33212244e2", "ve": 3.0, "vf": "2015-03-23 19:45:14", "vg": ["food"], "vj": ["m6"], "vk": "s0", "vc": "Android"}, {"va": 4, "vb": "kanishq-sharma-3393281", "vc": "Android", "ve": 3.0, "vf": "2015-03-23 19:45:14", "vg": [], "vk": "s1", "_id": "55c3256534876e33212244e3", "vj": ["m6"]}, {"va": 4, "vb": "kanishq-sharma-3393281", "vc": "Android", "ve": 3.0, "vf": "2015-03-23 19:45:14", "vg": ["price", "food quality"], "vk": "s1", "_id": "55c3256534876e33212244e4", "vj": ["m6"]}, {"va": 4, "vb": "kanishq-sharma-3393281", "vc": "Android", "ve": 3.0, "vf": "2015-03-23 19:45:14", "vg": ["service", "heavy rush"], "vj": ["m6"], "vk": "s2", "_id": "55c3256534876e33212244e5"}, {"va": 4, "vb": "kanishq-sharma-3393281", "vc": "Android", "ve": 3.0, "vf": "2015-03-23 19:45:14", "vg": ["north indian", "taste"], "vj": ["m6"], "vk": "s0", "_id": "55c3256534876e33212244e6"}, {"va": 5, "vb": "zainab606", "_id": "55c3259234876e33212244e7", "ve": 4.5, "vf": "2015-06-02 22:58:35", "vg": ["chats nation"], "vk": "s1", "vc": "Android", "vj": ["m6"]}, {"va": 5, "vb": "zainab606", "vc": "Android", "ve": 4.5, "vf": "2015-06-02 22:58:35", "vg": ["agra"], "vk": "s1", "_id": "55c3259234876e33212244e8", "vj": ["m6"]}, {"va": 5, "vb": "zainab606", "_id": "55c3259234876e33212244e9", "ve": 4.5, "vf": "2015-06-02 22:58:35", "vg": ["bhallas"], "vk": "s1", "vc": "Android", "vj": ["m6"]}, {"va": 5, "vb": "zainab606", "vc": "Android", "ve": 4.5, "vf": "2015-06-02 22:58:35", "vg": ["such yummy bhallas"], "vk": "s1", "_id": "55c3259234876e33212244ea", "vj": ["m6"]}, {"va": 5, "vb": "zainab606", "vc": "Android", "ve": 4.5, "vf": "2015-06-02 22:58:35", "vg": ["other chats"], "vk": "s1", "_id": "55c3259234876e33212244eb", "vj": ["m6"]}, {"va": 5, "vb": "tspshikari", "vc": "Android", "ve": 4.5, "vf": "2015-05-04 09:10:46", "vg": ["famous chaat wali gali", "various indian snacks", "aaloo", "aaloo tikki golgappe chila etc"], "vk": "s1", "_id": "55c3259234876e33212244ec", "vj": ["m6"]}, {"va": 5, "vb": "tspshikari", "vc": "Android", "ve": 4.5, "vf": "2015-05-04 09:10:46", "vg": ["aaloo tikki", "chila", "taste"], "vk": "s1", "_id": "55c3259234876e33212244ed", "vj": ["m6"]}, {"va": 5, "vb": "tspshikari", "vc": "Android", "ve": 4.5, "vf": "2015-05-04 09:10:46", "vg": ["other snacks"], "vk": "s1", "_id": "55c3259234876e33212244ee", "vj": ["m6"]}, {"va": 5, "vb": "pongo", "vc": "NA", "ve": 4.0, "vf": "2014-11-01 22:45:28", "vg": ["more popular chaat outlets", "agra"], "vk": "s1", "_id": "55c3259634876e33212244ef", "vj": ["m6"]}, {"va": 5, "vb": "pongo", "_id": "55c3259634876e33212244f0", "ve": 4.0, "vf": "2014-11-01 22:45:28", "vg": ["speciality", "aloo tikki golgappas paneer chillas", "papri chaat"], "vk": "s1", "vc": "NA", "vj": ["m6"]}, {"va": 5, "vb": "pongo", "vc": "NA", "ve": 4.0, "vf": "2014-11-01 22:45:28", "vg": ["disposable plates"], "vk": "s1", "_id": "55c3259634876e33212244f1", "vj": ["m6"]}, {"va": 5, "vb": "pongo", "vc": "NA", "ve": 4.0, "vf": "2014-11-01 22:45:28", "vg": ["aloo tikki", "bit", "taste"], "vk": "s1", "_id": "55c3259634876e33212244f2", "vj": ["m6"]}, {"va": 5, "vb": "pongo", "vc": "NA", "ve": 4.0, "vf": "2014-11-01 22:45:28", "vg": ["fresh ones", "cisp outer layer", "soft tasty filling"], "vk": "s1", "_id": "55c3259634876e33212244f3", "vj": ["m6"]}, {"va": 5, "vb": "pongo", "vc": "NA", "ve": 4.0, "vf": "2014-11-01 22:45:28", "vg": ["golgappas", "bit", "nice cold kesar kulfi", "stall", "next door.always", "meeting spot", "many agrites"], "vk": "s1", "_id": "55c3259634876e33212244f4", "vj": ["m6"]}, {"va": 7, "vb": "kanishq-sharma-3393281", "vc": "Android", "ve": 4.0, "vf": "2015-03-23 19:42:46", "vg": ["best bakery", "agra"], "vk": "s1", "_id": "55c325f734876e3321224511", "vj": ["m6"]}, {"va": 7, "vb": "kanishq-sharma-3393281", "vc": "Android", "ve": 4.0, "vf": "2015-03-23 19:42:46", "vg": [], "vk": "s1", "_id": "55c325f734876e3321224512", "vj": ["m6"]}, {"va": 7, "vb": "kanishq-sharma-3393281", "_id": "55c325f734876e3321224513", "ve": 4.0, "vf": "2015-03-23 19:42:46", "vg": ["chico lava cake", "dominos"], "vk": "s1", "vc": "Android", "vj": ["m6"]}, {"va": 7, "vb": "kanishq-sharma-3393281", "_id": "55c325f734876e3321224514", "ve": 4.0, "vf": "2015-03-23 19:42:46", "vg": ["fruit cake", "gloss icing"], "vk": "s1", "vc": "Android", "vj": ["m6"]}, {"va": 7, "vb": "kanishq-sharma-3393281", "_id": "55c325f734876e3321224515", "ve": 4.0, "vf": "2015-03-23 19:42:46", "vg": ["brown breads ans", "soup sticks", "taste"], "vk": "s1", "vc": "Android", "vj": ["m6"]}, {"va": 8, "vb": "manish-dhankher-1163412", "vc": "Android", "ve": 5.0, "vf": "2015-05-11 14:57:32", "vg": ["amazing hospitality", "chef siddharth", "team"], "vk": "s1", "_id": "55c3262734876e3321224516", "vj": ["m6"]}, {"va": 8, "vb": "manish-dhankher-1163412", "vc": "Android", "ve": 5.0, "vf": "2015-05-11 14:57:32", "vg": ["kids", "friendly restaurant", "big yes", "requests"], "vk": "s1", "_id": "55c3262734876e3321224517", "vj": ["m6"]}, {"va": 8, "vb": "manish-dhankher-1163412", "vc": "Android", "ve": 5.0, "vf": "2015-05-11 14:57:32", "vg": ["nice spread", "buffet"], "vk": "s1", "_id": "55c3262734876e3321224518", "vj": ["m6"]}, {"va": 10, "vb": "anurag-singh-8819021", "vc": "Android", "ve": 3.0, "vf": "2014-10-10 00:50:09", "vg": ["north indian food", "pocket"], "vk": "s1", "_id": "55c3268934876e3321224519", "vj": ["m6"]}, {"va": 10, "vb": "anurag-singh-8819021", "vc": "Android", "ve": 3.0, "vf": "2014-10-10 00:50:09", "vg": ["decent variety", "foods", "service"], "vk": "s1", "_id": "55c3268934876e332122451a", "vj": ["m6"]}, {"va": 10, "vb": "anurag-singh-8819021", "vc": "Android", "ve": 3.0, "vf": "2014-10-10 00:50:09", "vg": ["small parties"], "vk": "s1", "_id": "55c3268934876e332122451b", "vj": ["m6"]}, {"va": 10, "vb": "anurag-singh-8819021", "vc": "Android", "ve": 3.0, "vf": "2014-10-10 00:50:09", "vg": ["great taste"], "vk": "s1", "_id": "55c3268934876e332122451c", "vj": ["m6"]}, {"va": 11, "vb": "aye-erginbas-payal-11818251", "vc": "Android", "ve": 5.0, "vf": "2014-11-09 11:40:26", "vg": ["harikaaa bir yer", "tavsiye ederimmmm fiyatlarda", "uuk degilll bi deneyinnn derimmm"], "vk": "s1", "_id": "55c326b834876e332122451d", "vj": ["m6"]}], "date_code": {"d15": "last fifteen days", "m6": "last six months", "m1": "last one month", "m3": "last three months", "d7": "last seven days"}, "user_code": {"ue": "user link", "ud": "user id", "uf": "gender", "ua": "user name", "uc": "no of follower", "ub": "no of review"}, "sentiment_codes": {"s2": "negative", "s1": "positive", "s0": "neutral"}, "topic_review": {"tn": ["55c3254f34876e33212244da", "55c3256534876e33212244e5", "55c325f734876e3321224512", "55c3262734876e3321224516", "55c3262734876e3321224517", "55c3268934876e332122451a"], "to": ["55c3230b34876e33212244d2", "55c3230b34876e33212244d6", "55c3254f34876e33212244db", "55c3254f34876e33212244de", "55c3254f34876e33212244df", "55c3259234876e33212244eb", "55c3259234876e33212244ee", "55c3259634876e33212244f3"], "tl": ["55c3256534876e33212244e4", "55c3268934876e3321224519"], "tk": ["55c3259234876e33212244ed"], "tg": ["55c3254f34876e33212244d9", "55c3256534876e33212244e6"], "td": ["55c3230b34876e33212244cf", "55c3230b34876e33212244d0", "55c3230b34876e33212244d1", "55c3230b34876e33212244d4", "55c3230b34876e33212244d5", "55c3254f34876e33212244d7", "55c3254f34876e33212244d8", "55c3254f34876e33212244dd", "55c3254f34876e33212244e1", "55c3256534876e33212244e3", "55c3259234876e33212244e8", "55c3259234876e33212244ea", "55c3259234876e33212244ec", "55c3259634876e33212244ef", "55c3259634876e33212244f1", "55c3259634876e33212244f2", "55c3259634876e33212244f4", "55c325f734876e3321224511", "55c3262734876e3321224518", "55c3268934876e332122451b", "55c3268934876e332122451c", "55c326b834876e332122451d"], "te": ["55c3230b34876e33212244d3", "55c3254f34876e33212244dc", "55c3254f34876e33212244e0", "55c3256534876e33212244e2", "55c3259234876e33212244e7", "55c3259234876e33212244e9", "55c3259634876e33212244f0", "55c325f734876e3321224513", "55c325f734876e3321224514", "55c325f734876e3321224515"]}, "source_code": {"sr_1": "zomato"}, "restaurant_detail": [{"ro": "Agra Cantt", "rp": "Agra", "type_cuisine_done": "1", "rd": "https://www.zomato.com/agra/54tr-hotel-clarks-shiraz-agra-cantt", "re": 2.7, "rf": 2000, "rg": [], "ra": "NA", "rb": "Hotel Clarks Shiraz, 54, Taj Road, Agra Cantt, Agra", "rc": 7, "rl": 78.0249166667, "rm": 27.1588722222, "_id": 1, "rh": ["rt_1"], "ri": "NA", "rj": "54TR - Hotel Clarks Shiraz", "rk": "NA"}, {"ro": "Kuberpur", "rp": "Agra", "type_cuisine_done": "1", "rd": "https://www.zomato.com/agra/agra-bana-kuberpur", "re": 3.6, "rf": 800, "rg": ["cu_1", "cu_9", "cu_2", "cu_4"], "ra": "NA", "rb": "12/153A2, Near Itimad Ud Daulah, Nunihai Road, Yamuna Expressway, Kuberpur, Agra", "rc": 21, "rl": 78.0393361111, "rm": 27.1967222222, "_id": 3, "rh": ["rt_2"], "ri": "NA", "rj": "Agra Bana", "rk": "NA"}, {"ro": "Civil Lines", "rp": "Agra", "type_cuisine_done": "1", "rd": "https://www.zomato.com/agra/aahar-civil-lines", "re": 2.6, "rf": 700, "rg": ["cu_1", "cu_9", "cu_10", "cu_4"], "ra": "NA", "rb": "26/118, Opposite Income Tax Building, Sanjay Place, Civil Lines, Agra", "rc": 16, "rl": 78.00435, "rm": 27.1995388889, "_id": 4, "rh": ["rt_2"], "ri": "NA", "rj": "Aahar", "rk": "NA"}, {"ro": "Agra Cantt", "rp": "Agra", "type_cuisine_done": "1", "rd": "https://www.zomato.com/agra/agra-chat-house-agra-cantt", "re": 3.7, "rf": 150, "rg": ["cu_7"], "ra": "NA", "rb": "Sadar Bazar, Agra Cantt, Agra", "rc": 10, "rl": 78.0108333333, "rm": 27.1593166667, "_id": 5, "rh": ["rt_4"], "ri": "NA", "rj": "Agra Chat House", "rk": "NA"}, {"ro": "Civil Lines", "rp": "Agra", "type_cuisine_done": "1", "rd": "https://www.zomato.com/agra/atlantic-foods-civil-lines", "re": 3.4, "rf": 400, "rg": ["cu_13", "cu_10"], "ra": "NA", "rb": "G 26 114//2, Deep Shikha Tower, Sanjay Place, Civil Lines, Agra", "rc": 7, "rl": 78.0079111111, "rm": 27.2009805556, "_id": 7, "rh": ["rt_3"], "ri": "NA", "rj": "Atlantic Foods", "rk": "NA"}, {"ro": "Tajganj", "rp": "Agra", "type_cuisine_done": "1", "rd": "https://www.zomato.com/agra/alfresco-trident-hotel-tajganj", "re": "NA", "rf": 1800, "rg": ["cu_14"], "ra": "NA", "rb": "Trident Hotel, Fatehabad Road, Tajganj, Agra", "rc": "NA", "rl": 78.0598833333, "rm": 27.1595277778, "_id": 8, "rh": ["rt_1"], "ri": "NA", "rj": "Alfresco - Trident Hotel", "rk": "NA"}, {"ro": "Rakabganj", "rp": "Agra", "type_cuisine_done": "1", "rd": "https://www.zomato.com/agra/amazon-hookah-bar-lounge-hotel-yamuna-view-rakabganj", "re": "NA", "rf": 1000, "rg": ["cu_16"], "ra": "NA", "rb": "Hotel Yamuna View, The Mall Road, Rakabganj, Agra", "rc": "NA", "rl": 78.0146416667, "rm": 27.1647444444, "_id": 9, "rh": ["rt_6"], "ri": "NA", "rj": "Amazon Hookah Bar & Lounge - Hotel Yamuna View", "rk": "NA"}, {"ro": "Shahganj", "rp": "Agra", "type_cuisine_done": "1", "rd": "https://www.zomato.com/agra/anjali-restaurant-shahganj", "re": "NA", "rf": 500, "rg": ["cu_1", "cu_9", "cu_2", "cu_4"], "ra": "NA", "rb": "48, COD Colony, MG Road 2, Near Saket Colony, Shahganj, Agra", "rc": "NA", "rl": 77.983329, "rm": 27.18002, "_id": 10, "rh": ["rt_4"], "ri": "NA", "rj": "Anjali Restaurant", "rk": "NA"}, {"ro": "Tajganj", "rp": "Agra", "type_cuisine_done": "1", "rd": "https://www.zomato.com/agra/asia-cafe-tajganj", "re": "NA", "rf": 700, "rg": ["cu_1", "cu_4"], "ra": "NA", "rb": "Ram Shree Complex, Fatehabad Road, Tajganj, Agra", "rc": "NA", "rl": 78.0518277778, "rm": 27.158, "_id": 11, "rh": ["rt_2"], "ri": "NA", "rj": "Asia Cafe", "rk": "NA"}, {"ro": "Kamla Nagar", "rp": "Agra", "type_cuisine_done": "1", "rd": "https://www.zomato.com/agra/anant-restaurant-kamla-nagar", "re": "NA", "rf": 300, "rg": ["cu_9"], "ra": "NA", "rb": "Avas Vikas Colony, Kamla Nagar, Agra", "rc": "NA", "rl": 78.0190972222, "rm": 27.2094972222, "_id": 13, "rh": ["rt_2"], "ri": "NA", "rj": "Anant Restaurant", "rk": "NA"}, {"ro": "Rakabganj", "rp": "Agra", "type_cuisine_done": "1", "rd": "https://www.zomato.com/agra/agra-darbar-rakabganj", "re": "NA", "rf": 500, "rg": ["cu_4"], "ra": "NA", "rb": "Hotel KGN Basement, Near Baluganj Petrol Pump, Rakabganj, Agra", "rc": "NA", "rl": 78.0148305556, "rm": 27.166575, "_id": 14, "rh": ["rt_2"], "ri": "NA", "rj": "Agra Darbar", "rk": "NA"}, {"ro": "Mantola", "rp": "Agra", "type_cuisine_done": "1", "rd": "https://www.zomato.com/agra/aap-ki-khatir-restaurant-mantola", "re": "NA", "rf": 200, "rg": ["cu_4"], "ra": "NA", "rb": "Nai Ki Mandi, Mantola, Agra", "rc": "NA", "rl": 78.0016777778, "rm": 27.1829916667, "_id": 15, "rh": ["rt_2"], "ri": "NA", "rj": "Aap Ki Khatir Restaurant", "rk": "NA"}, {"ro": "Shahganj", "rp": "Agra", "type_cuisine_done": "1", "rd": "https://www.zomato.com/agra/adbhutlicious-shahganj", "re": "NA", "rf": 300, "rg": ["cu_4"], "ra": "NA", "rb": "2, MIG, MG Road 2, Shahganj, Agra 282010", "rc": "NA", "rl": "NA", "rm": "NA", "_id": 16, "rh": ["rt_5"], "ri": "NA", "rj": "Adbhutlicious", "rk": "NA"}, {"ro": "Lohamandi", "rp": "Agra", "type_cuisine_done": "1", "rd": "https://www.zomato.com/agra/agra-mutton-chicken-house-lohamandi", "re": "NA", "rf": 300, "rg": ["cu_4"], "ra": "NA", "rb": "44-46, Delhi Gate, Rajamandi Station Road, Lohamandi, Agra", "rc": "NA", "rl": 77.9983138889, "rm": 27.1954611111, "_id": 17, "rh": ["rt_2"], "ri": "NA", "rj": "Agra Mutton Chicken House", "rk": "NA"}, {"ro": "Kamla Nagar", "rp": "Agra", "type_cuisine_done": "1", "rd": "https://www.zomato.com/agra/anjuman-restaurant-bar-kamla-nagar", "re": "NA", "rf": 550, "rg": ["cu_1", "cu_2", "cu_4"], "ra": "NA", "rb": "Hotel Anjuman, Near Shri Ram Talkies, Bypass Road, Kamla Nagar, Agra", "rc": "NA", "rl": 78.0207138889, "rm": 27.2085583333, "_id": 18, "rh": ["rt_2"], "ri": "NA", "rj": "Anjuman Restaurant & Bar", "rk": "NA"}, {"ro": "Agra Cantt", "rp": "Agra", "type_cuisine_done": "1", "rd": "https://www.zomato.com/agra/agarwal-palace-restaurant-agra-cantt", "re": "NA", "rf": 500, "rg": ["cu_4"], "ra": "NA", "rb": "Hotel Agarwal Palace, 379, Station Road, Agra Cantt, Agra", "rc": "NA", "rl": 77.9946972222, "rm": 27.1583472222, "_id": 20, "rh": ["rt_2"], "ri": "NA", "rj": "Agarwal Palace Restaurant", "rk": "NA"}]}
<!DOCTYPE html>
<meta charset="utf-8">
<style> /* set the CSS */
body {
font: 12px
Arial;
}
path {
stroke: steelblue;
stroke-width: 2;
fill: none;
}
.axis path,
.axis line {
fill: none;
stroke: grey;
stroke-width: 1;
shape-rendering: crispEdges;
}
</style>
<body>
<script src="http://d3js.org/d3.v3.min.js"></script>
<script>
// Set the dimensions of the canvas / graph
var margin = {top: 30, right: 20, bottom: 30, left: 50},
width = 600 - margin.left - margin.right,
height = 270 - margin.top - margin.bottom;
var parseDate = d3.time.format("%Y-%m-%d").parse;
// Set the ranges
var x = d3.time.scale().range([0, width]);
var y = d3.scale.linear().range([height, 0]);
// Define the axes
var xAxis = d3.svg.axis().scale(x)
.orient("bottom")
var yAxis = d3.svg.axis().scale(y)
.orient("left")
// Define the line
var reviewline = d3.svg.line()
.x(function(d) { return x(d.date); })
.y(function(d) { return y(d.review); });
var svg = d3.select("body")
.append("svg")
.attr("width", width + margin.left + margin.right)
.attr("height", height + margin.top + margin.bottom)
.append("g")
.attr("transform",
"translate(" + margin.left + "," + margin.top + ")");
d3.json("rest_json.json", function(data){
var obj1={};
console.log(data.review_detail);
data.review_detail.forEach(function(d) {
console.log(d);
// d.Date = parseDate(d.Date);
sentiment=d.vk;
dDate = d.vf
if (obj1[dDate]==undefined)
{
obj1[dDate]={"s0":0,"s1":0,"s2":0};
obj1[dDate][sentiment]+=1;
}
else
{
obj1[dDate][sentiment]+=1;
}
});
console.log("line 76",obj1);
// Scale the range of the data
x.domain(d3.extent(data, function(d) { return d.date; }));
y.domain([0, d3.max(data, function(d) { return d.review; })]);
});
// Add the X Axis
svg.append("g")
.attr("class", "x axis")
.attr("transform", "translate(0," + height + ")")
.call(xAxis);
// Add the Y Axis
svg.append("g")
.attr("class", "y axis")
.call(yAxis);
});
</script>
</body>
答案 0 :(得分:0)