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.
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980import Highcharts from 'highcharts'import Exporting from 'highcharts/modules/exporting'Exporting(Highcharts)
const build_segment_graph = function(timing, segment, chartOptions) { if (document.getElementById(`segment-graph-holder-${segment.id}`) === null) { return }
const duration = `${timing}time_duration_ms`
let graph_data = [] const non_zero_values = segment.histories.filter((attempt) => attempt[duration] > 0) graph_data.push({ name: segment.name, data: non_zero_values.map(function(attempt) { return ['Attempt #' + attempt.attempt_number, attempt[duration]] }), pointStart: 1 })
Highcharts.chart('segment-graph-holder-' + segment.id, { exporting: { chartOptions: Object.assign(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}