score:1
See here the working DEMO.
The problem is that you are mistaken regarding the date initialization:
This is incorrect
var from_date='2014,30,06';
Date.UTC(from_date); //here variable value is passed as a single string with value : '2014,30,06'
This is correct
Date.UTC(2014,30,06);// This means that you are passing three different parameters "year", "month" and "day" for date initialization
So to initialize the date from string we have split the string using javascript split function
as shown below
var from_date='2014,30,06';
var arr_from_date = from_date.split(",");
//alert(arr_from_date[0]+" "+arr_from_date[1]+" "+arr_from_date[2]);
arr_from_date[0] //2014 has year value
arr_from_date[1] //30 has day value
arr_from_date[2] //06 has month value
So the final JS code is:
var from_date='2014,30,06';
var arr_from_date = from_date.split(",");
//alert(arr_from_date[0]+" "+arr_from_date[2]+" "+arr_from_date[1]);
var to_date='2014,30,07';
var arr_to_date = to_date.split(",");
var new_from_date = Date.UTC(arr_from_date[0], arr_from_date[2], arr_from_date[1]);
var new_to_date = Date.UTC(arr_to_date[0], arr_to_date[2], arr_to_date[1]);
$('#container').highcharts({
xAxis: {
type: 'datetime',
min: new_from_date,
max: new_to_date,
range: new_to_date - new_from_date,
ordinal: false,
endOnTick: false,
startOnTick: false
},
series: [{
data: [29.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4]
}]
});
score:1
The problem is how are you using Date.UTC()
. Date.UTC(year, month, day, .. )
is taking a couple of arguments, not one argument which is string, like this: '2014,30,06'
.
See example how this should be done: http://jsfiddle.net/LLExL/3049/
var from_date = '2014,30,06'.split(',');
var to_date = '2014,30,07'.split(',');
var min = Date.UTC(from_date[0], from_date[2], from_date[1]);
var max = Date.UTC(to_date[0], to_date[2], to_date[1]);
$('#container').highcharts({
xAxis: {
type: 'datetime',
min: min,
max: max,
range: max - min,
ordinal: false,
endOnTick: false,
startOnTick: false
},
series: [{
data: [29.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4]
}]
});
Note: Second argument (month) for Date.UTC()
is starting from 0 (January), not from 1 (which is February).
Source: stackoverflow.com
Related Query
- Highchart : by passing FROM DATE and TO DATE x axis labels should set
- change distance of x-axis labels from axis in highchart
- change distance of x-axis labels from axis in highchart
- Adding symbols and annotations to Highchart date axis
- How to show full date to my labels and each x axis in different colour in highcharts?
- how to add data from database and set it to data serie in highchart C#
- highchart x axis not showing correct date labels
- How to set y axis labels if it appears as [1,2.12,1.2,5 ] , they should be [1.00,2.12,1.20,5.00]
- move x and y axis from left to right in highchart
- When there is a plotband and a plotline emerging from yAxis how to set a particular width for plotband only in highchart
- Laravel Highcharts - Cant set value and labels from arrays
- How to set json data from url on highchart and polling the json data after 1 sec to dislay on highchart using Angular js
- Highcharts: Set y Axis Max and Min dynamically, and not at creation
- Displaying Persian dates in highchart from its corresponding Georgian date
- Populate Highcharts X-Axis With Dates Given a From And To Date
- How to dynamically change axis from linear to logarithmic in HighChart
- How to set dataLabel Format and axis label angle in R highcharter package
- How to place labels on opposite Y axis in Highchart without a second series
- how to assign date time to highchart with intervals and date start
- Set background color to HighChart xAxis labels
- How to set series-label to false by default and change the color of series label text in highchart
- How to remove the value and number labels from Highcharts angular gauge
- How can I set the alignment for individual axis labels in highcharts?
- Highchart offline export trying to loading libs from online cdn and errors out
- passing json values to highcharts from .net code behind
- Highchart Axis with only min and max series value
- Set left and right border-like on highchart
- Is it possible to have two Y Axis in a highstock chart from highcharts one on the left and another on the right?
- Set series color based on X axis on a column Highchart
- how to add dynamic y axis in highchart from specific point of x-axis
More Query from same tag
- Highcharts resize chart size using custom export button and replace expand and collapse button dynamically
- Get variable from data structure in highstock
- Add more data to High-chart X axis
- Meteor Highcharts using collection data
- Highcharts datalabels with gradient color
- Add picture issue when exporting Highcharts to pdf - Highcharts warning: Invalid tagName
- Can I sychronize two highcharts series with different years (leap year)
- Highlight a slice of pie chart in highcharts on click of a div
- Highcharts Export Server - Getting a blank chart
- Can't display x-axis value in Highcharts title
- How to Highcharts max height based on width of bars in chart
- highcharter: how can I customize the labels on a column plot
- HighChart: Show custom label on series (spline)
- Highcharts markers to appear only on x axis ticks
- R Shiny Highcharter - Add series without full reload
- how to show data label on mouse over in highcharts?
- Why I cant put the highcharts.chart in render?
- Highcharts - heatmap : avoid 0 on resize chart
- Highcharts do not render
- how to create a responsive custom label in highchart
- Highcharts update large array
- Library duplication issue using Highcharts in Jaspersoft Studio
- Highcharts sync is not working horizontally
- Loading JSON data in Ruby on rails to use HIGHCHARTS
- Highmaps redraw bug after update points (with enabled zoom)
- Highcharts.JS deleting data and freezing browser
- Highchart - show heatmap legend by category
- Highcharts not "graphing" in Firefox or Safari
- highcharts / stock charts custom toolbar button text / title
- Why highchart returning " Typeerror : undefined variable byte "?