score:10
i am amazed how difficult this is. not an optimal solution, but the best i can dream up with highchart's api:
var somedata = [1,5,82,9,300,5,42,199,5,6,99,1,56,52,250,64];
var chart = new highcharts.chart({
chart: {
renderto: 'container'
},
yaxis:{
min: -10,
tickinterval: 1,
labels: {
formatter: function() {
if (this.value < somedata[0])
return null;
else if (this.value == somedata[0])
return this.value;
else if (this.value % 50 == 0)
return this.value;
}
}
},
series: [{
data: somedata
}]
});
score:3
a solution (that optimizes marks answer) is to use yaxis.labels.formatter
with this.isfirst
and this.axis.datamin
, like this:
yaxis:{
labels: {
formatter: function() {
if(this.isfirst)
return this.axis.datamin;
return this.value;
}
}
}
see this jsfiddle demo for an example.
the advantage of this is that you do not have to manually set tickinterval
, which saves a lot of calls to formatter
and lets highcharts figure out the label intervals itself. also, it uses the axis knowledge of the minimum data value, instead of having to check against an array (which you may have to iterate over to find the minimum).
beware that the yaxis.min
must be set to something sensible here (works best with 0
, and positive data). if the y-axis goes far below the minimum datapoint the first label will not be the one at 0.
the this.axis
value was not available when this question was asked.
Source: stackoverflow.com
Related Query
- How to set a static minimum value for axes in Highcharts
- Set minimum data interval for y axes on Highcharts
- How to set Highcharts chart maximum yAxis value
- Highcharts - How to set custom colors for the series
- How do I set a minimum upper bound for an axis in Highcharts?
- Highcharts Bar Chart - How to set the minimum bar width/length
- How to set the x value for High Charts error bar
- Highcharts - how to set textShadow for data labels
- HighCharts - how to set labels font color for printing?
- Highcharts - How to set a gradient theme for each type of graph globally?
- How to set border for a highcharts pie?
- Can I set a minimum positive and a minimum negative axis value in Highcharts
- My Highcharts graph with multiple axis ignores the max value I set for the first yaxis
- How to set Highcharts xAxis position on the yAxis zero value (negative/positive chart)?
- Highcharts Theming: How to set gradient colors for certain chart types only?
- Highcharts how to make a set number of colors for pie chart data and drilldown data
- How to set xData as date (Y-M) for Highcharts synchronized charts?
- Highcharts minimum value for area charts y-axis
- How to set up zoomType for Highcharts with the CodeIgniter lib
- How to set maximum and minimum value color of highcharts?
- How to show horizontal line instead of a dot for a single value data in highcharts
- How to set min start date for Highcharts plot?
- How to position Highcharts tooltip on top of bar or at 0 line of Y-axis for negative value
- how to set negative axes intervals in highcharts
- how to set border radius for stacked bar in highcharts
- Highcharts Highmaps How to change value for color axis in map bubble
- How to set the fixed xAxis value in Highcharts
- How to set different colors for bars based on value in Highchart bar chart?
- How to set object value in color attribute for high charts legends?
- How do I get DateTime from mysql and set it to json format ready for highcharts
More Query from same tag
- When using Highcharts, how do you get the point name from a data point series?
- Highcharts: Decide on charts placement after generation
- How to set multiple colors in one series in highchart
- High Charts Data Table not filtering data by range selector
- Highcharts : axis with multiple colour
- Highchart, edit data from function call with arguments
- MySQL Data to Highchart's Pie Chart using JSON
- Use String as object in javascript?
- push data to line chart
- $.getJSON is not getting the values to show as a line graph
- vmware-clarity Type 'ElementRef' is not generic
- HighCharts: align rotated multiline label
- Highcharts pie wrong legend colors
- jsPDF - Getting black images on IE, but works fine on Chrome and FireFox
- Highcharts tooltip custom CSS turning the caret/arrow white
- How to display Multiple Highchart in single page
- Which one is better to represent an API fetched data in react js and please explain how to do that?
- react-highcharts Y-axis categories catch event click in react way
- Inner area color for pie-donut highchart
- Highcharts: Error bars in drill-down charts
- Get variable from data structure in highstock
- Remove datalabels from formatter with Highchart
- How to add an array to an existing two-dimensional array (for use in Highcharts)
- Highcharts - toggle table properly upon drilldown item
- How do i enable scrollbar in highcharts in react
- Can't show the array to charts
- Custom Drill No Longer Functioning
- HighCharts - Negative $ currency values
- Click event for bar-chart using Highcharts not working?
- How can i call java script function by clicking x Axis label on Highchart