score:1
is it possible to make highchart show a dynamic data base clicked button?
Yes you can do, before to set actual data you need to set first blank data in series then set actual data.
DEMO
var assets = [{
name: "food",
type: [{
name: "a",
y: 129.2
}, {
name: "b",
y: 132
}]
}, {
name: "drink",
type: [{
name: "drink1",
y: 512,
}, {
name: "drink2",
y: 412,
}]
}],
colors = ['#76daff', '#b9f', '#99ffa6', '#ffc312'];
$('button').on('click', function() {
var attr = $(this).attr('title'),
obj = assets.find(({name}) => name === attr);
chart.series[0].setData([], true);
chart.series[0].setData(obj.type || [], true);
});
var chart = Highcharts.chart('highchart', {
chart: {
type: 'bar',
backgroundColor: null,
height: 270,
},
title: {
text: ''
},
xAxis: {
type: 'category',
labels: {
useHTML: true,
formatter: function() {
return '<div class="myToolTip" style="color:' + colors[this.pos % colors.length] + '">' + this.value + '</div>';
}
}
},
colors: colors,
yAxis: {
min: 0,
gridLineWidth: 0,
title: {
text: ''
},
gridLineWidth: 0,
labels: {
enabled: false
}
},
credits: {
enabled: false
},
legend: {
enabled: false
},
plotOptions: {
series: {
dataLabels: {
enabled: true,
crop: false,
overflow: 'none',
format: '<span style="color:{point.color}">{y}</span>'
},
colorByPoint: true
}
},
tooltip: {},
series: [{}]
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://code.highcharts.com/highcharts.js"></script>
<div id="highchart"></div>
<button title="food">show food</button>
<button title="drink">show drink</button>
Source: stackoverflow.com
Related Query
- dynamic highchart series based on click
- Column based Highchart drilldown series assign color code to each column
- how to draw dynamic series in Highchart based on data
- Call an angular component method when we click on highchart series
- HighChart hide other series on click legend
- Use a symfony route with parameters in a click event for highchart series
- Set series color based on X axis on a column Highchart
- Unable to trigger a click event on series data | Highchart
- Drawind Dynamic series and points with Highchart and ajax
- Counting json data to create dynamic series in highchart line charts
- How to set the static series name to the element result based on the categories in the HighChart
- I am getting same highchart in pdf using jspdf when I am downloading the pdf with dynamic ids on click
- update table as we click on the stacked highchart based on some logic
- Highchart with dynamic scale for both series
- click dynamic highchart to open in new window
- Highchart series style on button click
- Highchart multiple level drilldown click event get drilldown series data
- disabling click event for a series highchart
- Highchart columnrange, color code lines based on data
- Dynamic add series and categories for highchart drill down chart
- Highchart - show / hide an y-Axis without hiding the series
- How to display highchart series line marker symbol from tooltip formatter?
- Highchart series update in javascript
- Reduce gap between series data in Bar Highchart
- Adding new HighChart Series
- Dynamic update of multiple series in highcharts
- Highchart dynamic creation - not rendering properly
- Selenium click on Highcharts series
- Highchart (Column Chart) : Few data labels are not appearing for a series
- Series markers disable on lines and enable on legend in Highchart
More Query from same tag
- Highcharts: Pie chart label overlap
- Highcharts - How to specify dimensions of rectangles
- Half node in sankey Highchart
- How to build a JSON data array for Highcharts display - switching values for xAxis/columns
- Highcharts: why does redrawing change the radius of the selected point?
- How to display yearly values on xAxis in Highcharts
- JSFiddle API examples are broken
- Grouped and stacked columns with shared series
- How do i make connectors (lines connecting datalabels) of piechart in Highcharts look straight lines and not curved?
- Highcharts labels appears twice
- OHLC tooltip getting duplicated to volume chart also in stock chart (highstock)?
- Highcharts gauge incorrectly rendering label values
- Highcharts: how display tooltip, when point = null?
- How to customize highchart box plot box
- Highcharts Multiple Series data - label mismatch
- Native Android SDK graph
- how to display charts/graphs based on user specific data
- Not able to go back to original state after drill down in highcharts
- Highcharts dynamic-update example - adding 1 new value every second - without historic data
- Highcharter - move data label to top of column
- Print Highstock with custom html
- Trouble showing results with pie highchart
- Highcharts Zoom in Logarithmic Scale
- R Highcharter: Formatting dual y-Axis chart
- How to add a plotline to a bar chart in Highcharts?
- Can you show/hide series in sunburst diagrams?
- Highcharts update chart scroll issue- scroll to initial position
- re-rendering EJS file after an ajax request
- R highcharter() global thousand separator?
- Make highchart columns extend to edge