How to use a gas gauge?
Gauging the level of battery charge is not trivial at all. Accurate gas gauges, for example from Texas Instruments, use a built-in powerful MCU to calculate the charge level based on particular (selectable) chemistry model, accurate charge-in and charge-out measurements, and also track impedance of cell to track battery aging and get more accurate results. Gauge architecture also varies depending on whether it is built into battery, or residing at system level. Start here, Accurate gauging products for any battery system overview.