charts icon indicating copy to clipboard operation
charts copied to clipboard

XAxis setTickInterval not working when enabling timeline

Open zaheer1389 opened this issue 6 years ago • 0 comments

when using timeline the setTickInterval() on XAxis not dividing the tick interval according to the passed value for AxisType.DATETIME.

protected Component getDataCoverageChart(PatientHealthData patientHealthData) {
        Chart chart = new Chart(ChartType.COLUMN);
        chart.setTimeline(true);
        chart.setHeight("100px");
        chart.setWidth("100%");
        
        Configuration configuration = chart.getConfiguration();
        //configuration.getChart().setZoomType(ZoomType.X);
        configuration.getChart().setSpacingRight(20);
        configuration.getRangeSelector().setEnabled(false);
        configuration.getTitle().setText("");
        
        configuration.getxAxis().setType(AxisType.DATETIME);
        
        XAxis xAxis = configuration.getxAxis();
        xAxis.setTickInterval(1000*60*60*2);
        //xAxis.setLabels(new Labels(false));
 
        configuration.getTooltip().setXDateFormat("%H:%M:%S.%L");
        configuration.getLegend().setEnabled(false);
        
        YAxis yAxis = configuration.getyAxis();
        yAxis.setOpposite(false);
        yAxis.setLabels(new Labels(false));
        yAxis.setTitle(new AxisTitle(""));
        //yAxis.setMin(0.6);
        //yAxis.setStartOnTick(false);
        //yAxis.setShowFirstLabel(false);

        configuration.setTooltip(null);

/*        PlotOptionsColumn plot = new PlotOptionsColumn();
        //plot.setPointWidth(1);
        plot.setPointPadding(0.2);
        plot.setBorderWidth(0);*/

        DataSeries listSeries = new DataSeries();
    	listSeries.setName("Data coverage");
    	//PlotOptionsArea options = new PlotOptionsArea();
        //listSeries.setPlotOptions(options);
        
    	if(patientHealthData.getHealthData() != null && patientHealthData.getHealthData().getHealthDataList().length > 0){
			HealthData healthData [] = patientHealthData.getHealthData().getHealthDataList();
			Arrays.sort(healthData);
			for(HealthData healthData2 : healthData){
				try {
					Date dt = simpleDateFormat.parse(healthData2.getTimerange());
					Double doubleVal = Double.parseDouble(healthData2.getRr());
					Double formattedValue = Double.parseDouble(decimalFormat.format(doubleVal));
					//System.out.println(dt+ " , "+doubleVal);
					String value = "1";
					listSeries.add(new DataSeriesItem(dt, Double.parseDouble(value)));
				} catch (Exception e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
			}
			
		}
    	configuration.setSeries(listSeries);

        chart.drawChart(configuration);
        return chart;
    }

zaheer1389 avatar Sep 24 '19 11:09 zaheer1389