The top seed and 20-time Grand Slam victor emerged from another nervy battle to eventually defeat the 28th-ranked Spaniard 6-3, 2-6, 6-4.
Argentine Juan Martin del Potro overcame a slow start to outlast France's Richard Gasquet 7-5 7-6 (7).
Djokovic's second-round victory improved his flawless record against the 41st-ranked Chardy to 12-0 in matches played, and 28-0 in sets won.
"As you can probably hear in my voice, I'm a little sick right now, so feeling a little bit low energy, but I hope it will get better over the next few days".
Del Potro, who similarly suffered with cold and flu in the China Open final, was broken on his service to immediately go a game down. Del Potro had the knee wrapped but called it quits after losing the first set 7-5.
Top seed and defending champion Roger Federer battled past in-form Russian Daniil Medvedev 6-4 4-6 6-4 to reach the last-16 at the Shanghai Masters on Wednesday. I like his demeanour, he is a great fighter and I like playing against those type of players.' Federer also analyzed his win over Daniil Medvedev: 'It was extremely hard, that is why I was very happy at the end. "I did everything that I needed to win". The second set was flawless, really.
Since Djokovic lost that French Open match to Cecchinato, he's won 28 of his 30 matches.
But the world number three exploded back to life mid-season, winning Wimbledon, the Cincinnati Masters and US Open. He's bidding to win a record fourth Shanghai title this week.
He will take on seventh-seeded Kevin Anderson of South Africa, whom he leads 6-1 on head-to-head.
Anderson ousted 10th-seeded Stefanos Tsitsipas of Greece 6-4, 7-6 (1).
Briton Kyle Edmund, who moved to a career-high ranking of 14 this week, continued his impressive run in Asia with a 7-5 6-3 win over Serbia's Filip Krajinovic.