While I'm dynamically building a chart, I need to add some SVG elements in it. To do so, I convert some coordinates into pixels coordinates via ToPixels.
However if I call ToPixels on my axes before it is being rendered, the value I'm getting is invalid. It should be around 800 and I'm getting values around 33000.
I have a workaround which is to call redraw before I call ToPixels but I don't think I should have to do that.
Related
I have a set of data consisting of 3 values, being time, dataValue, dataQuality. I'm trying to get the line color (not the marker because that is working) color set based on the dataQuality. The current graph is rendered based on time (x-axis) and dataValue (y-axis) and dataQuality is currently not used or shown.
What I would like tot have is the line color based on the data quality instead of the data value, all while rendering data value for the line.
Is this possible to achieve within hightcharts?
Edit: To clarify with an image, as requested. The red line is the only line I'd like tot render, the grey one is here solely to show the quality value for the data. So what I'd like is the red line to go grey (or whatever we decide it to be) as soon as the data from the other line drops below a threshold. The markers, even though done with paint here, are already done by setting the color value for individual markers grammatically when processing the incoming data. The grey line should not be rendered at all.
Alright, having a night of sleep over it helped. Instead of trying to do it the hard way, by using invisible values I though of another way to solve this.
I do know the timestamps for low quality points. I started using the timestamps on the x-axis to create zones with different colors. Which color for which zone is determined by the data quality.
Currently I am working on already established application which uses Core plot and in specific its using ScatterPlot to draw a graph. This graph is drawn with values obtained from connected bluetooth device so the graph is dynamically drawn.
XY graph with X axis having time value and Y axis having value from BLE device.
Now the requirement is to add an out of range value with a label "OL" in the graph and its not a fixed constant value for the bluetooth device(Its more of a state set in model object that is constructed in BLE layer with junk value obtained for that state and on which we can figure out its a out of range value).
So for e.g., if I get 'OL' value initially then I need to add it on graph above 0 with label "OL". '-OL' below 0 with label "-OL". The values obtained from BLE is continuously added to array and the graph is redrawn using this array.
So behaviour is expected as below:
If I get 200 as value in the array and if the array has OL value then OL value has to be plotted above 200 and if the next value from BLE is 300 which will be added to array and since OL is above 200, now OL has to be plotted above 300.
I tried 2-3 different approaches to figure out a solution for this but with no success.
Image of the expected requirement:
Require someone to help out if its possible to implement this using Core plot.
You'll need a second scatter plot for the red lines. In the main plot, return nil from the datasource for the values that are outside the valid range. This will leave gaps in the line, to be filled in with the other plot.
For the second plot, return nil from every data index, except ones that are out of the valid range. Return the range limit value for those points. You'll also need to return the correct in-range value for the two points on either side of the out-of-range values to connect the line to the main plot line.
I'm using the built-in spline curve fit to an x-y plot. Is there a way of getting access to the splined data that HighCharts itself is plotting? I (obviously) have access to my supplied x,y co-ordinates but I'd like access to the HighCharts-calculated spline intermediate values.
Take http://www.highcharts.com/demo/spline-symbols as an example. The raw data is (month,temperature) and the closest point to the mouse get displayed as a tooltip. I'm interested in displaying the intermediate 'points' so that as I move my mouse along a line it displays the calculated spline values.
Is this possible?
This has been dormant for a while but I did manage to figure out a way of doing it. See also a related follow up question.
Say you want to find a 'y' value for a given 'x' on a HighCharts generated spline. If you can get at the SVG path for that spline then you can walk it's length until you hit the required 'x'. Then read off the required 'y'.
This fiddle gives an example: https://jsfiddle.net/r3f2xL6b/1/
I am using ios-charts library to draw charts on a swift2 app. I am wondering if, for a given X value, I can change its Y associated value by a drag and drop gesture on the chart.
If this is not possible on this library, is it possible to do such a thing using another library?
technically you can. Every time you scroll/zoom the chart, it will trigger a redraw, so everything is redrawing, you can decide your own logic how you want the y axis value changed.
It has two parts:
In computeAxisValues in y axis renderer, the y axis labels(values) are determined. Then in renderAxisLabels, it is drawn using the calculated values.
So you can take a look at these functions and implement your logic. Note, it's your responsibility to make sure what you are doing is valid in your scenario, because if something weird happens, you may not get support on github, because it's not a bug, and sometimes not easy to answer.
I want to use core-plot for drawing line graph dynamically. data won't come at a time, we will be receiving point by point dynamically.
Is it possible to draw the chart dynamically using core-plot i.e drawing point by point as on when we receive the (x,y) point?
Please help me, Thanks.
Yes, you can do this reasonably easily. For each received data point, append it to an array of values to display. As these data points come in, call -reloadData on the Core Plot graph (or just the particular plot) to redraw the graph, passing in the array you just added a value to in response to the -numbersForPlot:field:recordIndexRange: delegate method.
If you need to adjust the plot range to track your data points (for a moving ticker), recalculate the new CPPlotRange for the X axis and set the plot space's xRange property to that.
Use the CPTestApp-iPhone, AAPLot, or StockPlot examples as templates for how to set up the line chart overall, and modify from that starting point.
I do something similar to this on the Mac in a scientific application:
(source: sunsetlakesoftware.com)
Sounds like you could make use of a demo project I put together and wrote about here (not core plot related though).
It draws a EKG graph but should easily be modified to use another input than the repeated "heart beat"...See line 320 in EAGLView.m where the indata is entered into the array.