Something went wrong. Try again.
[READ-ONLY] Mirror of https://github.com/glacials/splits-io. a speedrunning data store and analysis engine splits.io
Something went wrong. Try again.
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374import Highcharts from 'highcharts'import Exporting from 'highcharts/modules/exporting'Exporting(Highcharts)
const build_segment_graph = function(segment) { const url = new URL(window.location.href) const duration_string = `${url.searchParams.get('timing') || gon.run.default_timing}time_duration_ms`
let graph_data = [] const non_zero_values = segment.histories.filter((attempt) => attempt[duration_string] > 0) graph_data.push({ name: segment.name, data: non_zero_values.map(function(attempt) { return ['Attempt #' + attempt.attempt_number, attempt[duration_string]] }), pointStart: 1 })
Highcharts.chart('segment-graph-holder-' + segment.id, { exporting: { chartOptions: { plotOptions: { series: { dataLabels: { enabled: true } } } }, fallbackToExportServer: false }, chart: { borderRadius: 0, borderWidth: 0, plotBorderWidth: 0, zoomType: 'xy' }, legend: { enabled: false }, title: { text: segment.name + ' Duration over Time' }, plotOptions: { series: { connectNulls: true } }, tooltip: { shared: true, crosshairs: true, pointFormatter: function() { let time = moment.utc(moment.duration(this.y).asMilliseconds()).format('H:mm:ss') return `<span style="color:${this.color}">\u25CF</span> ${this.series.name}: <b>${time}</b><br/>` } }, xAxis: { title: { text: 'Attempt Number' } }, yAxis: { min: 0, title: { text: 'Duration of Segment' }, labels: { formatter: function() { return moment.utc(moment.duration(this.value).asMilliseconds()).format('H:mm:ss') } } }, series: graph_data })}
export {build_segment_graph}