|
Data from Cursor over price chart to clipboard |
Posted by icm63 on May-11-2017 02:33 |
|
Using the finance chart or XYchart using data to cursor, via code like
showText = "onmouseover='Javascript:ShowChartDataVOL1" & UserSymbolID.ToString & "(""{xLabel|mm/dd/yyyy}"",""{value|2}"",""{high|2}"", ""{low|2}"", ""{open|2}"", ""{close|2}"",""{x}"");'"
How can I get the DATE and/or CLOSE into the clip board so I can paste it to a text box, or go direct from clip board automatically to a text box.
I wish for the action of copy to clipboard and paste to text box on the event of CLICKING the chart so i guess it picks up X and Y or DATE and CLOSE ??
Any ideas??
|
Re: Data from Cursor over price chart to clipboard |
Posted by Peter Kwan on May-12-2017 03:44 |
|
Hi icm63,
I assume you already know how to obtain the necessary information (such as the DATE and CLOSE) from ChartDirector, as your code has already obtain the information. Once your code obtain the information, you can need to use normal Javascript code to copy to the clipboard. No ChartDirector code is needed.
For example, you may copy any information you need to a normal text box, then use the Javascript "select" method to select it, then use document.execCommand to copy the select text to the clipboard.
For more details, please refer to Javascript documentation.
Regards
Peter Kwan |
Re: Data from Cursor over price chart to clipboard |
Posted by icm63 on May-12-2017 06:18 |
|
Javascript events on VB charts
You have for javascripts
onmousemove, onmouseover
what else do you have??
What I need is a OnMouseClick event that sends chart data after a click event on the chart to a text box or label, as less steps involved.
from your manual this....
JsChartViewer.TouchMoveChart
Description
This event occurs when a Javascript touch move event occurs on the chart.
Use JsChartViewer.attachHandler with the event id "TouchMoveChart" to attach a handler to this event.
The JsChartViewer.getChartMouseX, JsChartViewer.getChartMouseY, JsChartViewer.getPlotAreaMouseX and JsChartViewer.getPlotAreaMouseY can be used to obtain the mouse or touch coordinates relative to the chart.
OR....
Maybe i could and a click event to the chart control and get it that way, would this work??
Any ideas??? |
Re: Data from Cursor over price chart to clipboard |
Posted by icm63 on May-12-2017 06:41 |
|
UPDATE
I tried onmouseclick (lowercase) where I use onmouseover
Did not work...
Any ideas |
Re: Data from Cursor over price chart to clipboard |
Posted by icm63 on May-12-2017 06:51 |
|
OOOPS my mistake
These are the events you can use instead of onmouseover
onclick
onmousedown
onmousedown
etch
https://www.w3schools.com/jsref/dom_obj_event.asp
All good thanks |
Re: Data from Cursor over price chart to clipboard |
Posted by Peter Kwan on May-12-2017 23:45 |
|
Hi icm63,
As you include only one line of code in your message (the showText line), it is hard for me to trouble-shoot the code. There is a chance the issue is not related to that line.
Anyway, I have modified the original "Finance Chart (1)" sample code to include an onclick event handler, and it works normally. The following is the code for your reference.
<%@ Page Language="VB" Debug="true" %>
<%@ Import Namespace="ChartDirector" %>
<%@ Register TagPrefix="chart" Namespace="ChartDirector" Assembly="netchartdir" %>
<!DOCTYPE html>
<script runat="server">
'
' Page Load event handler
'
Protected Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs)
' Create a finance chart demo containing 100 days of data
Dim noOfDays As Integer = 100
' To compute moving averages starting from the first day, we need to get extra data points
' before the first day
Dim extraDays As Integer = 30
' In this exammple, we use a random number generator utility to simulate the data. We set up the
' random table to create 6 cols x (noOfDays + extraDays) rows, using 9 as the seed.
Dim rantable As RanTable = New RanTable(9, 6, noOfDays + extraDays)
' Set the 1st col to be the timeStamp, starting from Sep 4, 2002, with each row representing one
' day, and counting week days only (jump over Sat and Sun)
rantable.setDateCol(0, DateSerial(2002, 9, 4), 86400, True)
' Set the 2nd, 3rd, 4th and 5th columns to be high, low, open and close data. The open value
' starts from 100, and the daily change is random from -5 to 5.
rantable.setHLOCCols(1, 100, -5, 5)
' Set the 6th column as the vol data from 5 to 25 million
rantable.setCol(5, 50000000, 250000000)
' Now we read the data from the table into arrays
Dim timeStamps() As Double = rantable.getCol(0)
Dim highData() As Double = rantable.getCol(1)
Dim lowData() As Double = rantable.getCol(2)
Dim openData() As Double = rantable.getCol(3)
Dim closeData() As Double = rantable.getCol(4)
Dim volData() As Double = rantable.getCol(5)
' Create a FinanceChart object of width 640 pixels
Dim c As FinanceChart = New FinanceChart(640)
' Add a title to the chart
c.addTitle("Finance Chart Demonstration")
' Set the data into the finance chart object
c.setData(timeStamps, highData, lowData, openData, closeData, volData, extraDays)
' Add the main chart with 240 pixels in height
c.addMainChart(240)
' Add HLOC symbols to the main chart, using green/red for up/down days
Dim layer As HLOCLayer = c.addHLOC(&H008000, &Hcc0000)
Dim showText As String = "onclick='test(""{xLabel|mm/dd/yyyy}"", ""{close|2}"");'"
layer.setHTMLImageMap("", "", showText)
' Output the chart
WebChartViewer1.Image = c.makeWebImage(Chart.PNG)
WebChartViewer1.ImageMap = c.getHTMLImageMap("")
End Sub
</script>
<html>
<body>
<script>
function test(xLabel, close)
{
alert("[" + xLabel + "] " + close);
}
</script>
<chart:WebChartViewer id="WebChartViewer1" runat="server" />
</body>
</html>
Hope this can help.
Regards
Peter Kwan |
Re: Data from Cursor over price chart to clipboard |
Posted by icm63 on May-13-2017 02:21 |
|
Thanks, works here tooo!! |
|