score:6
I could not figure out how to convert SVG data into what is displayed on the graph you mentioned, but wrote the following Selenium Python script:
from selenium import webdriver
import time
driver = webdriver.Chrome()
driver.get('https://www.bestfightodds.com/events/ufc-fight-night-108-swanson-vs-lobov-1258')
actions = webdriver.ActionChains(driver)
actions.move_to_element(driver.find_element_by_id('oID1013467091'))
actions.click()
actions.perform()
time.sleep(3)
driver.switch_to_active_element()
chart_number = driver.find_element_by_id('chart-area').get_attribute('data-highcharts-chart')
chart_data = driver.execute_script('return Highcharts.charts[' + chart_number + '].series[0].options.data')
for point in chart_data:
e = driver.execute_script('return oneDecToML('+ str(point.get('y')) + ')')
print(point.get('x'), e)
Here we are using Highcharts API and some js from the page sources, that converts server response for this chart to what we see on a graph.
score:0
When I use the CSS selector "g.highcharts-axis-labels tspan"
it returns all the fighter's names and when I use "g.highcharts-data-labels tspan"
it returns all the percents for line movement.
So you should be able to use something like
labels = driver.find_elements_by_css_selector("g.highcharts-axis-labels tspan")
data = driver.find_elements_by_css_selector("g.highcharts-data-labels tspan")
for i in range(0, len(labels) - 1)
print("Fighter: " + labels[i] + " (" + data[i] + ")")
An alternative is to use the command that Pawel Fus recommended,
Highcharts.charts[0].series[0].options.data
You should be able to execute that using JSE and it returns an array of arrays. You can then parse through that and get the data you want. It's up to you...
score:1
Reconstructing data from the svg data list described above using the linear equation y = mx + b
from the highcharts chart is another method. If actual data values are known, and datapoints are often displayed on highcharts charts, the slope can be calculated very accurately. Given the intercept is known (see below) I ran a regression on 3 known points and it calculated them precisely (zero error).
Another method described in detail here is reconstructing the data from the highcharts-yaxis-labels
but the suitability depends on the data and required accuracy. Extract the y
and text
values as x
and y
respectively and run a regression analysis.
y="148"... >-125<
y="117"... >+100<
y="85"... >+120<
y="54"... >+140<
y="23"... >+160<
It is useful to plot the values in a chart, especially with this case because the relationship is not linear. Fortunately discarding the -125
value gives a nice straight line and none of the values are less than 100
.
x y
117 100
85 120
54 140
23 160
x -0.638938504720592
R^2 0.999938759887726
The bottom x
is the line slope so m
= -0.638938504720592
.
What about the intercept? The most common coordinate system has a bottom left origin but svg uses a top left coordinate system. This means the intercept will have to be adjusted to the top of the chart. The easiest way given this dataset has a value for the top of the chart is to just use the top y
as b
= 160
.
Extract the data list using your preferred method (not described in this answer) and reconstruct the data with the linear equation.
eg ...L 999999 101 ....
y
= -0.638938504720592
* 101
+ 160
= 95
Reconstructing the data from the y-axis may not be as accurate as using the actual data. If you are lucky the yaxis-labels
scale will have a nice scale so you get precise values but it can be up to half a unit out on the top and bottom of the range, so (1/2 + 1/2) / 94 = 1.06% in this example but the error is likely much less.
Source: stackoverflow.com
Related Query
- Converting svg from Highcharts data into data points
- Highcharts displays series names but missing data points from json source
- Passing data from db into Highcharts in Rails 3.x
- Loading data from API into a highcharts vue component
- Getting data from Postgres in JSON format in ROR into a Highcharts javascript
- Plotting Highcharts Chart from multiple data points in json
- Passing Returned Data from a PHP Script into a Highcharts data[] block?
- Highcharts SVG Export from Python Server Side Code
- Highcharts how to pass data from server into chart
- get data from hashmap into highcharts
- what should be the initial dataset from millions of data points for stock line highcharts
- highcharts - pulling data from HTML but converting the strings to number
- Highcharts prevent page on mobile Safari from moving up and down as I scroll horizontally through data points
- Get SVG Data from Highcharts without displaying the chart
- Proper way to remove all series data from a highcharts chart?
- Python: Read data from Highcharts after setExtreme
- Resize data points with highcharts
- Highcharts doesn't display series with lots of data points
- Load data into Highcharts with Ajax
- Scraping data from Highcharts using selenium
- Send JSON data to highcharts pie from asp.net MVC controller in C#
- How to get multiple data series into Highcharts
- How to pass custom data into Highcharts graph click event
- Highcharts scatter plot with lots of data points running really slow
- How can I delete all of the points from a highcharts series
- highcharts with null data points
- Add dynamic data to line chart from mysql database with highcharts
- Find number of data points in each series in highcharts
- How can i change highcharts data values by selecting from a dropdown list
- Using PhantomJS to create HighCharts grahps server side for use in PDF creation (PHP) - results in exit code 11 from PHPs exec();
More Query from same tag
- Rails, Highchart maps - adding custom data
- Legend item hiding/showing other legend items
- how to draw charts with json file data in highcharts
- Highcharts adding url to column chart
- Can I assign a different radius for each pie slice using Highcharts?
- Highcharts HeatMap cell color disappears when hover in Internet Explorer
- Create Pie chart for each Json object
- Is it possible to have the line chart data points in highcharts to be represented as a rectangle instead of a circle?
- Combining categories for column chart with Highcharts
- How to add Legend in highchart compare stock chart
- Generic HighCharts (Javascript\Java)
- how to animate highcharts marker symbol on chart load
- Highcharts rangeselector navigation - start on the lowest date / value
- Highcharts doesn't display data
- Highchart loses fillOpacity when fillColor is specified
- How to access Highcharts stock tooltip data in Vue?
- Get a reference to a Highcharts chart
- Highchart Tool-tio show CSV data
- world map not displaying - Angular Highcharts
- Highcharts xAxis text matching series name
- How to hide one series data info in tooltip using highcharts
- How to make the legend come in the image in highcharts?
- How to change color of donut chart in highchart?
- Referencing a JSON object created in Java through javascript in the one JSP page
- Highcharts not rendering in Angular 2 when I use data from http.get
- Higcharts: How to remove the tooltip on the xAxis?
- How to resize this highchart graph?
- Cannot find Component identifier in JSF
- How to update/add Highchart options/properties after the chart/object has been created?
- Default highstock zoom without rangeSelector buttons