Jump to content
JChartFX Community

Miguel

Members
  • Posts

    5
  • Joined

  • Last visited

  • Days Won

    2

Posts posted by Miguel

  1. Hello,

     I'm trying to paint a chart with two X axis. Both of them will be Date axis. In the first X-axis, I want to display hours with a certain step. In the second one, I want to display the month with another step.

    How could I do this?

    This is the code about the X-axis:

                            var axis = chart1.getAxisX();

    axis.getLabelsFormat().setFormat(cfx.AxisFormat.Time);

    axis.setStep(19);

    axis.getLabelsFormat().setCustomFormat("HH:mm");

    chart1.getAxisX().getGrids().setInterlaced(false);

     

                            var axisX2 = new cfx.AxisX();

     

    chart1.getAxesX().add(axisX2);

    axisX2.setVisible(true);

    axisX2.getLabelsFormat().setFormat(cfx.AxisFormat.Time);

    axisX2.getLabelsFormat().setCustomFormat("MM-dd");

    axisX2.getGrids().setInterlaced(false);

                axisX2.getGrids().getMajor().setVisible(false);

            axisX2.setPosition(cfx.AxisPosition.Far);

            axisX2.setStyle(cfx.AxisStyles.Centered); 

     

    I only get to display de first X axis. Why I cant display nothing in the second one?

     

    Thanks 

    • Like 2
  2. Thanks for your reply. It'works.

    But I have some doubts about my X-axis.

    I have date values of three diferent days, and I want to paint values that represent the hour, with a interval of 4 hour(00:00,04:00,08:00.......). And I would like another x-axis, placed above of the chart, with the 3 diferents days of my dataset. Would It be this possible?

    I only get to paint 1 X-axis with 2 values (02:00,02:00) and I don't know why paint this values. If I change the step of the axis- I can't see anything.

     

    Some idea.

    The series are correct, It only doesn't work the X-axis value. 

    Thanks in advance. 

     

  3. 
    

    Hello everybody,

     I'm trying to paint a chart with three Y-axis and a Date X-axis. When I parse my Json, I have this data array:

     var items = [
    		{"CoplanarIrradiance": 760,"AirTemperature": 35,"SurfaceTemperature": 32,"Time": "2014-Apr-27T18:15:00"},                                                                 {"CoplanarIrradiance": 460,"AirTemperature": 25,"SurfaceTemperature": 31,"Time": "2014-Apr-27T18:30:00"},                                                                 {"CoplanarIrradiance": 34,"AirTemperature": 2,"SurfaceTemperature": 32,"Time": "2014-Apr-27T18:45:00"},                                                                 {"CoplanarIrradiance": ,"AirTemperature": ,"SurfaceTemperature": 32,"Time": "2014-Apr-27T19:00:00"}, ... ]
    But I don't get to paint the chart. It only appears the X-axis, and it's incorrect. 
    This is my code:
     			chart1.setDataSource(data);	

    // Eje de Tiempo (X)

    var axis = chart1.getAxisX().getLabelsFormat().setFormat(cfx.AxisFormat.Date);

    chart1.getAxisX().getLabelsFormat().setCustomFormat(";MMM-dd");

    // Eje de Coplanar Irradiance(Y)

    var axis1 = chart1.getAxisY();

    axis1.getTitle().setText("Coplanar Irradiance (W/m2)");

    axis1.getGrids().getMajor().setVisible(false);

    axis1.getDataFormat().setFormat(cfx.AxisFormat.Number);

    axis1.getDataFormat().setDecimals(2);

    // Eje de Air Temperature (Y)

    var axis2 = chart1.getAxisY2();

    axis2.getTitle().setText("Air Temperature ©");

    axis2.setPosition(cfx.AxisPosition.Near);

    axis2.getGrids().getMajor().setVisible(false);

    chart1.getAxisY2().getDataFormat().setFormat(cfx.AxisFormat.Number);

    axis2.getDataFormat().setDecimals(2);

    // Eje de Surface Temperature (Y)

    var axis3 = new cfx.AxisY();

    chart1.getAxesY().add(axis3);

    axis3.getTitle().setText("Surface Temperature ©");

    axis3.setVisible(true);

    axis3.setPosition(cfx.AxisPosition.Far);

    axis3.getLabelsFormat().setFormat(cfx.AxisFormat.Number);

    axis3.getDataFormat().setDecimals(2);

    // Especificamos que hay tres series de datos.

    chart1.getData().setSeries(3);

    var series1 = chart1.getSeries().getItem(0);

    var series2 = chart1.getSeries().getItem(1);

    var series3 = chart1.getSeries().getItem(2);

    series1.setAxisY(axis1);

    series2.setAxisY(axis2);

    series3.setAxisY(axis3);

    series1.setGallery(cfx.Gallery.Lines);

    series2.setGallery(cfx.Gallery.Lines);

    series3.setGallery(cfx.Gallery.Lines);

    // ----Assign data fields--------

    var fields = chart1.getDataSourceSettings().getFields();

    var field = new cfx.FieldMap();

    var field2 = new cfx.FieldMap();

    var field3 = new cfx.FieldMap();

    field.setName("CoplanarIrradiance");

    field.setUsage(cfx.FieldUsage.Number);

    fields.add(field);

    field2.setName("AirTemperature");

    field2.setUsage(cfx.FieldUsage.Number);

    fields.add(field2);

    field3.setName("SurfaceTemperature");

    field3.setUsage(cfx.FieldUsage.Number);

    fields.add(field3);

    var legendBox = chart1.getLegendBox();

    legendBox.setDock(cfx.DockArea.Bottom);

    legendBox.setContentLayout(cfx.ContentLayout.Center);

    // ----Set Sample Data------------

    var divHolder = document.getElementById('meteo_pop_up_grafica_imagen');

    chart1.create(divHolder);

     And this is the result chart:
     
     What is the problem? The dataset is correct. 
    Thanks in advance 
×
×
  • Create New...