Posts

Showing posts with the label charts

How to add extra data in chart.js barchart tooltip

Image
Clash Royale CLAN TAG #URR8PPP How to add extra data in chart.js barchart tooltip I have a bar chart which i am building with chart.js I am fetching an extra data country wise on the click of the specific bar which is returning me two values I want to show the data values in the tooltip I have tried mode :label and callbacks of tooltip but not able to so please can someone have an idea how it can be done buildTheBarChart() { this.barChartService.getDataForSitesConnected(); this.barChartService.getDataForSitesConnected().then((countryValue: any) => { this.countryValue = countryValue; console.log('the response is ' , countryValue[0].countryName); this.countryNames = ; this.countOfSites = ; this.countryIdArray = ; for (let i = 0 ; i < countryValue.length; i++) { this.countryNames.push(countryValue[i].countryName); this.countOfSites.push(countryValue[i].countSites); this.countryIdArray.push(countryValue[i].co...

How to show bars in JFreeChart which has 0 for the Y Axis?

Image
Clash Royale CLAN TAG #URR8PPP How to show bars in JFreeChart which has 0 for the Y Axis? I am having a clustered bar chart generated from JFreeChart . I have observed that the bars will only appear once the Y Axis value is greater than 0. I need to show the bars which has Y Axis value 0 also. I have searched many times in google, but I couldn't find a solution for this. Appreciate if you can help me to do this. My Code: public static void generateBarChart() throws IOException, ParseException { final DefaultCategoryDataset dataset = new DefaultCategoryDataset( ); dataset.addValue( 0 , "Failed" , "Spec 1" ); dataset.addValue( 3 , "Passed" , "Spec 1" ); dataset.addValue( 0 , "Skipped" , "Spec 1" ); dataset.addValue( 2 , "Failed" , "Spec 2" ); dataset.addValue( 0 , "Passed" , "Spec 2" ); dataset.addValue( 1 , "Skipped" , ...

How to create a image of a chart with Java

Image
Clash Royale CLAN TAG #URR8PPP How to create a image of a chart with Java I need to create a chart by reading some entries in my DB. I just want to create a image of the chart and create a new png. I prefer to do this with Java native libraries, so far I was able to get the following working. import javafx.application.Application; import javafx.collections.FXCollections; import javafx.collections.ObservableList; import javafx.embed.swing.SwingFXUtils; import javafx.scene.Scene; import javafx.scene.image.WritableImage; import javafx.stage.Stage; import javafx.scene.chart.*; import javafx.scene.Group; import java.io.File; import java.io.IOException; import java.nio.file.Path; import java.nio.file.Paths; import javax.imageio.ImageIO; public class Test extends Application { @Override public void start(Stage stage) { Scene scene = new Scene(new Group()); stage.setTitle("Imported Fruits"); stage.setWidth(500); stage.setHeight(500); Observ...