import com.aurorarnd.gfcharts.client.*;
This is how my Project Explorer sidebar looks like. I have named the project as hellocharts. // Create the Data Object FusionChartData chartData = new FusionChartData(); // Add Chart Properties chartData.addChartProperty("caption", "Pie Chart"); chartData.addChartProperty("numberPrefix", "$"); // Add Data Sets to Chart // Create Data Set FusionChartDataSet dataSet = new FusionChartDataSet("Item A", "25"); dataSet.addDataSetProperty("color", "AFD8F8"); chartData.addDataSet(dataSet); // Create Data Point // (data set for this plugin; data point with respect to FusionCharts) dataSet = new FusionChartDataSet("Item B", "17"); dataSet.addDataSetProperty("color", "F6BD0F"); chartData.addDataSet(dataSet); // Create Data Point dataSet = new FusionChartDataSet("Item C", "23"); dataSet.addDataSetProperty("color", "8BBA00"); dataSet.addDataSetProperty("isSliced", "1"); chartData.addDataSet(dataSet); // Create Data Point dataSet = new FusionChartDataSet("Item D", "65"); dataSet.addDataSetProperty("color", "A66EDD"); chartData.addDataSet(dataSet); // Finally create the chart itself FusionChartWidget chart = new FusionChartWidget(FusionCharts.Pie2D, chartData); chart.setTransparent(true); // Now add it to a container somePanel.add(chart);And the resulting pie chart is shown below:
FusionChartExtendedData
, and not FusionChartData
as we had done above. Also, being a multi-series chart, you have to set the data values for each series appropriately. We will also specify the primary and secondary Y-axes in this chart. Let us see how. Create a new project if you would like to in Eclipse, or just delete the code for the previous pie chart code and begin with this new code. // Create the Data Object FusionChartExtendedData chartData = new FusionChartExtendedData(); // Add Chart Properties chartData.addChartProperty("caption", "Population Chart"); chartData.addChartProperty("showValues", "0"); chartData.addChartProperty("sNumberSuffix", "%"); chartData.addChartProperty("decimals", "3"); chartData.addChartProperty("setAdaptiveYMin", "1"); chartData.addChartProperty("setAdaptiveSYMin", "1"); chartData.addChartProperty("lineThickness", "5"); // Add Chart Categories chartData.addCategory("2000"); chartData.addCategory("2001"); chartData.addCategory("2002"); chartData.addCategory("2003"); chartData.addCategory("2004"); chartData.addCategory("2005"); // Create Data Set FusionChartExtendedDataSet dataSet = new FusionChartExtendedDataSet(); // Add Data Set Properties dataSet.addDataSetProperty("seriesname", "Population"); // Add Data Set Values dataSet.addValue("275562673"); dataSet.addValue("278558081"); dataSet.addValue("280562489"); dataSet.addValue("290342551"); dataSet.addValue("290342551"); dataSet.addValue("293027112"); // Add Data Set To The Chart Data Object chartData.addDataSet(dataSet); // Create Data Set dataSet = new FusionChartExtendedDataSet(); // Add Data Set Properties dataSet.addDataSetProperty("parentYAxis", "S"); dataSet.addDataSetProperty("seriesname", "Birth Rate"); // Add Data Set Values dataSet.addValue("1.42"); dataSet.addValue("1.42"); dataSet.addValue("1.41"); dataSet.addValue("1.414"); dataSet.addValue("1.413"); dataSet.addValue("1.414"); // Add Data Set To The Chart Data Object chartData.addDataSet(dataSet); // Create Data Set dataSet = new FusionChartExtendedDataSet(); // Add Data Set Properties dataSet.addDataSetProperty("parentYAxis", "S"); dataSet.addDataSetProperty("seriesname", "Death Rate"); // Add Data Set Values dataSet.addValue("0.87"); dataSet.addValue("0.87"); dataSet.addValue("0.87"); dataSet.addValue("0.844"); dataSet.addValue("0.834"); dataSet.addValue("0.825"); // Add Data Set To The Chart Data Object chartData.addDataSet(dataSet); // Finally Create The Chart Itself FusionChartWidget chart = new FusionChartWidget(FusionCharts.MSCombiDY2D, chartData); chart.setTransparent(true); // Now add it to a container somePanel.add(chart);Finally, the resulting chart would look as the one below:
We’re excited to announce the upcoming release of FusionCharts v4.1—a groundbreaking step forward in the…
Have you ever been overwhelmed by a massive data set and wondered, "How do I…
If you’ve ever tried to make sense of the stock market, you’ve probably come across…
Imagine you’re comparing the sales performance of your top product lines across different regions, or…
Have you ever spent hours buried in documentation, hunting for a specific piece of code?…
Do you feel like your data is a cryptic puzzle, locked away from revealing its…