i integrating flask app highcharts , highcharts graph blend of 2 lines (one spline , other scatterplot). line shows correct date format in tooltip whereas scatter plot not.
i did see link can done writing javascript code:
tooltip: { crosshairs: true, formatter: function () { return '<b>' + highcharts.dateformat('%e. %b %y, %h:00', this.x) + '</b> ' + this.series.name + ': ' + this.y + ' m/s'; } } i want without writing javascript code.
my main python code this:
series = [ { "type":"scatter", "name": 'data points', "data":modified_result, "tooltip":{"xdateformat":'%y-%m-%d'} }, { "type":"spline", "name": 'trend line', "data":line_result, "tooltip":{"xdateformat":'%y-%m-%d'} } ] and render template saying:
return flask.render_template('index.html', result = result, predicted_prices = predicted_prices, chartid=chartid, chart=chart, series=series, title=title, xaxis=xaxis, yaxis=yaxis) and in index.html, have:
<script> var chart_id = {{ chartid|safe }} var series = {{ series|safe }} var title = {{ title|safe }} var xaxis = {{ xaxis|safe }} var yaxis = {{ yaxis|safe }} var chart = {{ chart|safe }} which calls javascript:
$(document).ready(function() { $(chart_id).highcharts({ chart: chart, title: title, xaxis: xaxis, yaxis: yaxis, series: series }); });
the 'scatter' type has little bit different setup tooltip. take @ answer. can in series setup code xdateformat.
{ "type":"scatter", "name": 'data points', "data":modified_result, "tooltip":{ "xdateformat":'%y-%m-%d', "headerformat": '{point.key}<br />', "pointformat": '<span style="color:{point.color}">\u25cf</span> {series.name}: <b>{point.y}</b><br/>' } } you can play around inside of here set more finely how want it. sample fiddle.
Comments
Post a Comment