Re: Plotting two line charts

"Nathaniel G. Auvil" <[email protected]> Fri, 16 Jul 2004 06:10:54 -0700 (PDT)
Newsgroups gmane.comp.krysalis.jcharts.devel
Message-ID <[email protected]>
sounds cool.  Thre are a couple of Validations against the ChartType Object...but I cannot think
of anything which would cause a problem.

Do you think we should do anything special in the Legend to denote what is plotted against which
axis?



--- Chris McKay <[email protected]> wrote:
> A little while ago I discussed the requirement for plotting one set of
> data points as a line chart against a LHS Y axis and another set, also
> as a line chart, against the right hand side Y axis.
> 
> I've come up with a solution which doesn't look too bad but I'd like to
> ask around to see if it would break anything.
> 
> At present DataSet now has a boolean property plotAgainstRHS, which is
> set at creation time. (Second parameter). 
> 
>         axisChartDataSet = new AxisChartDataSet(lineData, true,
> lineLegendLabels, linePaints, ChartType.LINE, lineChartProperties);
>         dataSeries.addIAxisPlotDataSet(axisChartDataSet);
> 
> Now DataSeries DataSets are stored in a HashMap, keyed by the ChartType
> object (hence no allowance for two DataSets of ChartType.LINE), so we
> create a second set of ChartTypes which are identical to the original
> except for the addition of a boolean plotAgainstRHS. This also has the
> effect of any comparisions being unchanged - the equality only being
> done on the int value, This means that
> (ChartType.LINE).equals(ChartType.LINE_RHS) so no mods required anywhere
> else that I can think of. 
> 
> And so creation of a DataSet being plotted against RHS now just uses new
> type:
> 
>         axisChartDataSet = new AxisChartDataSet(lineData,
> lineLegendLabels, linePaints, ChartType.LINE_RHS, lineChartProperties);
>         dataSeries.addIAxisPlotDataSet(axisChartDataSet);
> 
> 
> So a change to AxisChartDataSet.getPlotAgainstRHS method (yeah I'll
> change it to isPlottedAgainstRHS eh?)
> 	public final boolean getPlotAgainstRHS()
> 	{
> 		return this.chartType.isPlottedAgainstRHS();
> 	}
> 
> And the addition of the boolean variable to the ChartType class and
> final object creation.
> types.ChartType:
> 
> 	public static final ChartType LINE=new ChartType( 3, false );
> 	public static final ChartType LINE_RHS=new ChartType( 3, false,
> true );
> 
> And a new constructor:
> 
> 	private ChartType( int typeCode, boolean stackedData, boolean
> plotAgainstRHS )
> 	{
> 		super( typeCode );
> 
> 		this.stackedData=stackedData;
> 		this.plotAgainstRHS = plotAgainstRHS;
> 	}
> 
> Plus method:
> 	public boolean isPlottedAgainstRHS()
> 	{
> 		return this.plotAgainstRHS;
> 	}
> 
> 
> And so the only other change required is in axisChart.AxisChart so that
> we check for both types of LINE charts:
> 	protected void overlayCharts() throws PropertyException,
> ChartDataException
> 	{
> 		iAxisPlotDataSet =
> this.iAxisDataSeries.getIAxisPlotDataSet( ChartType.LINE );
> 		if( iAxisPlotDataSet != null )
> 		{
> 			LineChart.render( this, ( IAxisChartDataSet )
> iAxisPlotDataSet );
> 		}
> 		iAxisPlotDataSet =
> this.iAxisDataSeries.getIAxisPlotDataSet( ChartType.LINE_RHS );
> 		if( iAxisPlotDataSet != null )
> 		{
> 			LineChart.render( this, ( IAxisChartDataSet )
> iAxisPlotDataSet );
> 		}
> 
> 
> Pros:
> Very few changes to classes
> Cons:
> Will doing twice the number of HashMap lookups slow things down any in
> AxisChart?
> Will the introduction of new ChartTypes break anything? 
> 
> Line charts look OK, legends are drawn etc. At present the name of the
> legend is what signifies what axis it is being plotted against. I guess
> we could do a 2 column thing as an option?
> 
> 
> 
> 
> -------------------------------------------------------
> This SF.Net email is sponsored by BEA Weblogic Workshop
> FREE Java Enterprise J2EE developer tools!
> Get your free copy of BEA WebLogic Workshop 8.1 today.
> http://ads.osdn.com/?ad_id=4721&alloc_id=10040&op=click
> _______________________________________________
> jCharts-developers mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/jcharts-developers
> 


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 


-------------------------------------------------------
This SF.Net email is sponsored by BEA Weblogic Workshop
FREE Java Enterprise J2EE developer tools!
Get your free copy of BEA WebLogic Workshop 8.1 today.
http://ads.osdn.com/?ad_id=4721&alloc_id=10040&op=click