I want to show, depending on the selected checkbox respectively the corresponding graphs.
How do I link the checkbox with the graph, so that the graph is visible or invisible?
This is my code:
Code: Select all
\documentclass[12pt,a4paper]{article} % Use A4 paper with a 12pt font size
\usepackage[left=2.0cm,right=1.0cm,top=1.3cm,bottom=3.0cm,marginparwidth=3.4cm]{geometry} % Adjust page margins
\usepackage[colorlinks=true, pdfborder={0 0 0}, hidelinks]{hyperref} % this is needed for forms and links within the text
\usepackage{pgfplots} %Required for graph
\usepackage{eforms}
\usepackage[pdftex]{insdljs}
%_________________________________________________________________________
%the identifier is used create a temporary file which store the packed JavaScript code
\begin{insDLJS}[axxy]{axxy}{Document Level JavaScript}
function ThrottleType(){
console.println('Value id: ' + event.target.name);
if(event.target.name == "ACD"){
app.alert("AC");
}else if (event.target.name == "DCD"){
app.alert("DC");
}
}
\end{insDLJS}
%_________________________________________________________________________
\definecolor{Ocolor}{rgb}{0.95 0.4 0.12}
\newcommand{\XStart}{0,0}
\newcommand{\XStop}{5,0}
\newcommand{\YStart}{0,2}
\newcommand{\YStop}{0,-2}
\newcommand{\drawCoordinateSystem}{
\draw[step=.5cm, very thin,color=lightgray] (0,-1.5) grid (4.5,1.5);
\draw [->] (\XStart) -- (\XStop) node[right]{$T$};
\draw [<->](\YStop) -- (\YStart) node[above] {$F$};
}
\newcommand{\drawSIN}{
\begin{tikzpicture}
\drawCoordinateSystem
\draw[domain=0:4, ultra thick, Ocolor] plot (\x,{sin(pi*\x r})node[right, above]{$I$};
\end{tikzpicture}}
\newcommand{\drawDC}{
\begin{tikzpicture}
\drawCoordinateSystem
\draw[domain=0:2, thick, black, ->] (0,1) -- (4.5,1) node[right, above]{$I$} ;
\draw[domain=0:2, very thick, Ocolor] (0.,0)
\foreach \x in {0.0,0.40,...,3.6}
{(\x,.85) -- (\x+0.20,1.15) -- (\x+0.40,.85)};
\end{tikzpicture}
}%end newCommand
\newcommand{\FixedCheckBox}[2][]{\CheckBox[#1,borderwidth=0.5pt, width=0.5cm]{#2}}
%“running in backwards compatibility mode” Compiler Warning
\pgfplotsset{compat=newest,compat/show suggested version=false}
\begin{document}
\begin{Form}
\section{Anwendungen}%
\FixedCheckBox[name=ACD, validate={ThrottleType();}] {AC-Drossel}\hspace{2cm}%
\FixedCheckBox[name=DCD, validate={ThrottleType();}]{DC-Drossel}%
\begin{center}
\drawSIN
%
\hspace{2cm}
%
\drawDC
\end{center}
\end{Form}
\end{document}