make stackedBarChart function more versatile