Data silverData= DataUtil.scaleWithinRange(0, MAX_MEDALS, Arrays.asList(21, 38, 21, 13, 10));
Data bronzeData= DataUtil.scaleWithinRange(0, MAX_MEDALS, Arrays.asList(28, 36, 28, 15, 15));
BarChartPlot gold = Plots.newBarChartPlot(goldData, GOLD, "Gold");
BarChartPlot silver = Plots.newBarChartPlot(silverData, SILVER, "Silver");
BarChartPlot bronze = Plots.newBarChartPlot(bronzeData, Color.BROWN, "Bronze");
BarChart chart = GCharts.newBarChart(gold, silver, bronze);
// Defining axis info and styles
AxisStyle axisStyle = AxisStyle.newAxisStyle(BLACK, 13, AxisTextAlignment.CENTER);
AxisLabels country = AxisLabelsFactory.newAxisLabels("Country", 50.0);
country.setAxisStyle(axisStyle);
AxisLabels countries = AxisLabelsFactory.newAxisLabels("Germany", "United Kingdom", "Russia", "USA", "China");
countries.setAxisStyle(axisStyle);
AxisLabels medals = AxisLabelsFactory.newAxisLabels("Medals", 50.0);
medals.setAxisStyle(axisStyle);
AxisLabels medalCount = AxisLabelsFactory.newNumericRangeAxisLabels(0, MAX_MEDALS);
medalCount.setAxisStyle(axisStyle);
// Adding axis info to chart.
chart.addXAxisLabels(medalCount);
chart.addXAxisLabels(medals);
chart.addYAxisLabels(countries);
chart.addYAxisLabels(country);
chart.addTopAxisLabels(medalCount);
chart.setHorizontal(true);
chart.setSize(450, 650);
chart.setSpaceBetweenGroupsOfBars(30);
chart.setTitle("2008 Beijing Olympics Medal Count", BLACK, 16);
///51 is the max number of medals.
chart.setGrid((50.0/MAX_MEDALS)*20, 600, 3, 2);
chart.setBackgroundFill(Fills.newSolidFill(LIGHTGREY));
LinearGradientFill fill = Fills.newLinearGradientFill(0, Color.newColor("E37600"), 100);
fill.addColorAndOffset(Color.newColor("DC4800"), 0);
chart.setAreaFill(fill);
String url = chart.toURLString();
// EXAMPLE CODE END. Use this url string in your web or
// Internet application.
Logger.getLogger(Logger.GLOBAL_LOGGER_NAME).info(url);
String expectedString = "http://chart.apis.google.com/chart?chf=bg,s,D3D3D3|c,lg,0,E37600,1.0,DC4800,0.0&chs=450x650&chd=e:..tLc3X2UF,aWvraWQUMj,jItLjIS0S0&chtt=2008+Beijing+Olympics+Medal+Count&chts=000000,16&chg=19.6078431372549,600.0,3,2&chxt=y,y,t,x,x&chxl=0:|Germany|United+Kingdom|Russia|USA|China|1:|Country|4:|Medals&chxs=0,000000,13,0|1,000000,13,0|2,000000,13,0|3,000000,13,0|4,000000,13,0&chxp=1,50.0|4,50.0&chxr=1,0.0,100.0|2,0.0,51.0|3,0.0,51.0|4,0.0,100.0&chdl=Gold|Silver|Bronze&chco=FFD700,C0C0C0,A52A2A&chbh=23,4,30&cht=bhg";