Skip to content

XAxis setTickInterval not working when enabling timeline #585

@zaheer1389

Description

@zaheer1389

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;
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions