Remove image drawn on Highchart - highcharts

I have drawn one image on high-chart using chart.render.img method of high-chart. Now after clicking on button I want to update the coordinates of this img. But, there is no update function for image, I am trying to remove and again add it with new coordinates. So I have stored img in one array and using this array element I am trying to remove the image.
But It is not working.
var symbol = new Array();
symbol[0]= chart.renderer.image('assets/shared/images/green-line.png', xpoint, offset, width,height);
symbol[0].add();
Now after this i want to update the xpoint, offset, width & height. So I am removing this img.
$(symbol[0].element).remove();
Then I want to again add it using add method with new coordinates. This remove is not working.

Just call "destroy" method:
symbol[0].destroy();

Related

Reset Line position after window resize

I'm developing an App where I want to draw lines on an Image. The Image can be zoomed in and out, and dragged. I used self.to_widget() method of the Scatter class, so that the coordinates with respect to the Image will remain the same after zooming and dragging.
I wanted to implement a reset button, that would allow to reset the position and size of the image with respect to the the Window size. Here I'm facing the problem that the coordinates of the lines are changing with respect to the Image.
Knowing that the Image is a Child of a Scatter class with id: scatter_class, here is the code for the reset button:
def reset_position(self):
self.initial_width = Window.size[0]
self.initial_height = Window.size[1]
self.ids.scatter_class.pos = (
self.initial_width * 0.25,
self.initial_height * 0.5 - self.ids.main_image.height * 0.5,
)
I read that making changes in a Scatter class, won't affect its children, that's why probably the Line position are not updating with respect to the Image. I tried updating the position of the Lines using the to_widget() Method, to recalculate the coordinates with respect to the new position and size of the image, but it seems like I'm missing something.
Any Ideas?
Thanks in Advance!

Add marker on highchart

How to add markers at particular points (x,y) in high-chart line graph?
I have tried this:-
marker: {
symbol: 'square'
}
Am adding x and y values as dynamic array.I need to iterate the array in a loop and plot markers manually at certain points .Is it possible?
probably the best way to do it is to add a data series that represents the marker, so it would be something like this (pseudo-code):
var myMarkerPosition = myValueFromArray;
mychart.addSeries(myMarkerPosition);
and you can then do something like:
mychart.series[1].update({ symbol: square });
later on if you want to. Don't forget to replace your marker if you want to move it to another position by updating it.

iOS Core Plot X Axis text + icon

Hope you people doing great.I am new to Core Plot api and need your suggestion.I want to customize x index of plot and wants to add icon and label to each index.As I have searched , I got to make policy none to index but I want to add image to each label.Help will be much appreciated.
Custom axis labels don't have to be just text. The label's contentLayer can be any CPTLayer. Depending on what you're trying to achieve, you could render your text and label into an image and use that as the fill for a CPTBorderedLayer, add the icon (in a bordered layer) as a sublayer to the text layer for the label, or even create a custom CPTLayer subclass that draws everything the way you want it.

How do you convert a single UIView so that you can draw it within an existing PDF?

I am creating a PDF with labels, tables, and charts. I have no problem drawing images and text, but I have PDF charts that are custom UIViews.
The current context is set initially for drawing the PDF, and most of the questions here are relating to that. But I am talking about, once you're already drawing a PDF, how do you add a single additional view like you would add a line of text or an image. i.e. I want to add a UIView that contains a pie chart to a PDF I am creating.
I tried converting the view to an image, but it ends up pretty low resolution and you can seed the pixelation, whereas if you draw it directly it uses vector graphics and comes out much crisper.
PieChartView is from an open source github library. The manager is a simple custom class I wrote to manage it.
CGRect frame = CGRectMake(PAGE_WIDTH/2 - pieWidth/2, origin.y, pieWidth, pieHeight);
PieChartView* pie = [[PieChartView alloc] initWithFrame:frame];
PieChartManager* pieManager = [[BPPieChartManager alloc] initWithData:data];
pie.delegate = pieManager;
pie.datasource = pieManager;
[pie.layer drawInContext:UIGraphicsGetCurrentContext()];
This results in the pie chart filling the entire page of the PDF. This isn't surprising, since its layer doesn't contain information about the frame.
I guess I am supposed to use CGContextTranslateCTM and CGContextScaleCTM to reposition, but I'm not sure if there isn't a simpler way, plus I'm not sure how to use them to get what I want.
Thanks for your help
EDIT: I tried just drawing the pie this way:
[pie drawRect: frame];
That draws the pie in the top left of the page, in the size that's expected. How do I get it where I want it? The frame contains the origin of where I want it, so why is it putting it in the top left?
It appears as if the custom UIView which renders inside the pdf will always start from (0,0).
You can add the your pie view for the entire frame of the pdf page and draw the actual pie chart at a custom smaller frame in your UIView's drawRect function and make the remaining area transparent.

Draw only part of data in Highcharts

I looking for a way to only draw part of the data set in area chart. There is a slider above the chart that can limit the range of one series in the chart while other stile rendered in whole. I wonder whats the best way to do this. The only idea at the moment is to redraw the chart every time the slider moves but I'm afraid this could result in worse performance. Maybe this could be done with something like mask on the SVG element.
I came up with a simple solution by just clipping the svg graph with an clip path:
//var chart is the actual HighChartsInstance;
var renderer = chart.renderer;
var group = renderer.g().add();
var clipPath = renderer.createElement("clipPath");
clipPath.element.id = 'clip';
var rect = renderer.rect(0, 0, 200, 400).add(clipPath);
this.clippingMask = rect.element; //reference to the clipping rect which width is changed by the slider
clipPath.add(group);
chart.series[1].group.element.setAttribute('clip-path', "url(#clip)");
chart.series[1].group.element.childNodes[0].setAttribute('clip-path', "url(#clip)");
You have a few ways
use highstock which contains "slider" http://www.highcharts.com/stock/demo/
use highstock.js and highcharts chart with scroller http://jsfiddle.net/UCmUx/
scrollbar:{
enabled:true
},
use highcharts chart without scroller http://jsfiddle.net/UCmUx/1/ and in case when you move your own scroller, then use setExtremes() http://api.highcharts.com/highcharts#Axis.setExtremes()
I think one option is to modify the series data which you want to restrict, and then call:
chart.series[n].setData(newData);
where 'n' is the number of the series you are truncating. newData is a copy of the series data with the unwanted points taken out. You will need to specify x and y values in the series in order for it to be plotted in the correct position.

Resources