Jump to content
JChartFX Community
  • 0

CustomGridLine and Date X Axis


LunkwillAndFook

Question

1 answer to this question

Recommended Posts

  • 0

You can use the Chart.dateToDouble method to translate a javascript date (note that it expects a date not a string) into a number, e.g.

   var data = [

                 { "Date": "2013-10-01T00:00:00.000Z", "Value": 15 },

                 { "Date": "2013-11-01T00:00:00.000Z", "Value": 9 },

                 { "Date": "2013-12-01T00:00:00.000Z", "Value": 12 },

                 { "Date": "2014-01-01T00:00:00.000Z", "Value": 14 },

                 { "Date": "2014-02-01T00:00:00.000Z", "Value": 18 },

                 { "Date": "2014-03-01T00:00:00.000Z", "Value": 9 },

                 { "Date": "2014-04-01T00:00:00.000Z", "Value": 12 },

                 { "Date": "2014-05-01T00:00:00.000Z", "Value": 15 },

                ];


    var axisX = chart1.getAxisX();

    axisX.getLabelsFormat().setFormat(cfx.AxisFormat.Date);

    axisX.getLabelsFormat().setCustomFormat("MMM yyyy");

    

    var dateToday = new Date(2014, 2, 12, 0, 0, 0, 0);

    var customGrid = new cfx.CustomGridLine();

    var value = cfx.Chart.dateToDouble(dateToday);

    customGrid.setValue(value);

    axisX.getCustomGridLines().add(customGrid);

    

    chart1.setDataSource(data);

 

JuanC 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...