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.
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879import 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' }, colors: ['#fff'], legend: { enabled: false }, title: { text: 'Segment Duration over Time' }, plotOptions: { series: { connectNulls: true } }, tooltip: { shared: true, crosshairs: true, pointFormatter: function() { let time = moment.duration(this.y).format('H:mm:ss') return `<span style="color: #fff">\u25CF</span> ${this.series.name}: <b>${time}</b><br/>` } }, xAxis: { allowDecimals: false, lineColor: '#fff', title: { text: 'Attempt Number' } }, yAxis: { gridLineColor: 'rgba(1, 1, 1, 0.3)', min: 0, tickColor: 'rgba(1, 1, 1, 0.3)', title: { text: 'Duration of Segment' }, labels: { formatter: function() { return moment.duration(this.value).format('H:mm:ss') } } }, series: graph_data })}
export {build_segment_graph}