Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LineChart series sample #1

Open
decebals opened this issue Mar 13, 2012 · 15 comments
Open

LineChart series sample #1

decebals opened this issue Mar 13, 2012 · 15 comments

Comments

@decebals
Copy link

Hi

It's series supported for LineChart? Can you write a simple demo (a new method in JqPlotSample is enough)?

Thanks,
Decebal

@inaiat
Copy link
Owner

inaiat commented Mar 13, 2012

Hello,

a example like this (Line Style Options)
http://www.jqplot.com/deploy/dist/examples/line-charts.html ?

Thanks.

On Tue, Mar 13, 2012 at 9:24 AM, Decebal Suiu <
[email protected]

wrote:

Hi

It's series supported for LineChart? Can you write a simple demo (a new
method in JqPlotSample is enough)?

Thanks,
Decebal


Reply to this email directly or view it on GitHub:
#1

@decebals
Copy link
Author

Exact.

I wrote some code but I cannot obtains a LineChart with two series. I
don't know the relations between serie and the values from that serie
(jqplot it's new for me).

Thanks,
Decebal

On Tue, Mar 13, 2012 at 3:47 PM, Inaiat Henrique
[email protected]
wrote:

Hello,

a example like this (Line Style Options)
http://www.jqplot.com/deploy/dist/examples/line-charts.html ?

Thanks.

On Tue, Mar 13, 2012 at 9:24 AM, Decebal Suiu <
[email protected]

wrote:

Hi

It's series supported for LineChart? Can you write a simple demo (a new
method in JqPlotSample is enough)?

Thanks,
Decebal


Reply to this email directly or view it on GitHub:
#1


Reply to this email directly or view it on GitHub:
#1 (comment)

@inaiat
Copy link
Owner

inaiat commented Mar 13, 2012

Hello,

I developed LineSeriesChart. Checkout latest version. See example:

private LineSeriesChart<Double,Double> lineSeries() {
List<LineSeriesItem<Double, Double>> cosPoints = new
ArrayList<LineSeriesItem<Double, Double>>();
for (double i = 0; i < 2 * Math.PI; i++) {
cosPoints.add(new LineSeriesItem<Double, Double>(i,Math.cos(i)));
}

List<LineSeriesItem<Double, Double>> sinPoints = new
ArrayList<LineSeriesItem<Double, Double>>();
for (double i = 0; i < 2 * Math.PI; i+=0.4) {
sinPoints.add(new LineSeriesItem<Double, Double>(i,2 * Math.sin(i-.8)));
}

List<LineSeriesItem<Double, Double>> powPoints1 = new
ArrayList<LineSeriesItem<Double, Double>>();
for (double i = 0; i < 2 * Math.PI; i++) {
powPoints1.add(new LineSeriesItem<Double, Double>(i,2.5 + Math.pow(i / 4,
2)));
}

List<LineSeriesItem<Double, Double>> powPoints2 = new
ArrayList<LineSeriesItem<Double, Double>>();
for (double i = 0; i < 2 * Math.PI; i ++) {
powPoints2.add(new LineSeriesItem<Double, Double>(i,-2.5 - Math.pow(i / 4,
2)));
}

LineSeriesChart<Double,Double> lineChart = new
LineSeriesChart<Double,Double>("Line Style Options");
lineChart.addValue(cosPoints);
lineChart.addValue(sinPoints);
lineChart.addValue(powPoints1);
lineChart.addValue(powPoints2);
SeriesDefaults seriesDefaults = new SeriesDefaults();
seriesDefaults.rendererOptions(new RendererOptions().smooth(true));
lineChart.setSeriesDefaults(seriesDefaults);
lineChart.addSerie(new Serie().lineWidth(2).markerOptions(new
MarkerOptions().style("diamond")));
lineChart.addSerie(new Serie().showLine(false).markerOptions(new
MarkerOptions().size(7f).style("x")));
lineChart.addSerie(new Serie().markerOptions(new
MarkerOptions().style("circle")));
lineChart.addSerie(new Serie().lineWidth(5).markerOptions(new
MarkerOptions().style("filledSquare").size(10f)));

return lineChart;
}

On Tue, Mar 13, 2012 at 10:55 AM, Decebal Suiu <
[email protected]

wrote:

Exact.

I wrote some code but I cannot obtains a LineChart with two series. I
don't know the relations between serie and the values from that serie
(jqplot it's new for me).

Thanks,
Decebal

On Tue, Mar 13, 2012 at 3:47 PM, Inaiat Henrique
[email protected]
wrote:

Hello,

a example like this (Line Style Options)
http://www.jqplot.com/deploy/dist/examples/line-charts.html ?

Thanks.

On Tue, Mar 13, 2012 at 9:24 AM, Decebal Suiu <
[email protected]

wrote:

Hi

It's series supported for LineChart? Can you write a simple demo (a new
method in JqPlotSample is enough)?

Thanks,
Decebal


Reply to this email directly or view it on GitHub:
#1


Reply to this email directly or view it on GitHub:

#1 (comment)


Reply to this email directly or view it on GitHub:
#1 (comment)

@decebals
Copy link
Author

I cannot find LineSeriesChart on github.

On Tue, Mar 13, 2012 at 11:51 PM, Inaiat Henrique
[email protected]
wrote:

Hello,

I developed LineSeriesChart. Checkout latest version. See example:

private LineSeriesChart<Double,Double> lineSeries() {
List<LineSeriesItem<Double, Double>> cosPoints = new
ArrayList<LineSeriesItem<Double, Double>>();
for (double i = 0; i < 2 * Math.PI; i++) {
cosPoints.add(new LineSeriesItem<Double, Double>(i,Math.cos(i)));
}

List<LineSeriesItem<Double, Double>> sinPoints = new
ArrayList<LineSeriesItem<Double, Double>>();
for (double i = 0; i < 2 * Math.PI; i+=0.4) {
sinPoints.add(new LineSeriesItem<Double, Double>(i,2 * Math.sin(i-.8)));
}

List<LineSeriesItem<Double, Double>> powPoints1 = new
ArrayList<LineSeriesItem<Double, Double>>();
for (double i = 0; i < 2 * Math.PI; i++) {
powPoints1.add(new LineSeriesItem<Double, Double>(i,2.5 + Math.pow(i / 4,
2)));
}

List<LineSeriesItem<Double, Double>> powPoints2 = new
ArrayList<LineSeriesItem<Double, Double>>();
for (double i = 0; i < 2 * Math.PI; i ++) {
powPoints2.add(new LineSeriesItem<Double, Double>(i,-2.5 - Math.pow(i / 4,
2)));
}

LineSeriesChart<Double,Double> lineChart = new
LineSeriesChart<Double,Double>("Line Style Options");
lineChart.addValue(cosPoints);
lineChart.addValue(sinPoints);
lineChart.addValue(powPoints1);
lineChart.addValue(powPoints2);
 SeriesDefaults seriesDefaults = new SeriesDefaults();
seriesDefaults.rendererOptions(new RendererOptions().smooth(true));
lineChart.setSeriesDefaults(seriesDefaults);
 lineChart.addSerie(new Serie().lineWidth(2).markerOptions(new
MarkerOptions().style("diamond")));
lineChart.addSerie(new Serie().showLine(false).markerOptions(new
MarkerOptions().size(7f).style("x")));
lineChart.addSerie(new Serie().markerOptions(new
MarkerOptions().style("circle")));
lineChart.addSerie(new Serie().lineWidth(5).markerOptions(new
MarkerOptions().style("filledSquare").size(10f)));

return lineChart;
}

On Tue, Mar 13, 2012 at 10:55 AM, Decebal Suiu <
[email protected]

wrote:

Exact.

I wrote some code but I cannot obtains a LineChart with two series. I
don't know the relations between serie and the values from that serie
(jqplot it's new for me).

Thanks,
Decebal

On Tue, Mar 13, 2012 at 3:47 PM, Inaiat Henrique
[email protected]
wrote:

Hello,

a example like this (Line Style Options)
http://www.jqplot.com/deploy/dist/examples/line-charts.html ?

Thanks.

On Tue, Mar 13, 2012 at 9:24 AM, Decebal Suiu <
[email protected]

wrote:

Hi

It's series supported for LineChart? Can you write a simple demo (a new
method in JqPlotSample is enough)?

Thanks,
Decebal


Reply to this email directly or view it on GitHub:
#1


Reply to this email directly or view it on GitHub:

#1 (comment)


Reply to this email directly or view it on GitHub:
#1 (comment)


Reply to this email directly or view it on GitHub:
#1 (comment)

@inaiat
Copy link
Owner

inaiat commented Mar 14, 2012

Sorry! check again!

Thanks!

On Wed, Mar 14, 2012 at 6:35 AM, Decebal Suiu <
[email protected]

wrote:

I cannot find LineSeriesChart on github.

On Tue, Mar 13, 2012 at 11:51 PM, Inaiat Henrique
[email protected]
wrote:

Hello,

I developed LineSeriesChart. Checkout latest version. See example:

private LineSeriesChart<Double,Double> lineSeries() {
List<LineSeriesItem<Double, Double>> cosPoints = new
ArrayList<LineSeriesItem<Double, Double>>();
for (double i = 0; i < 2 * Math.PI; i++) {
cosPoints.add(new LineSeriesItem<Double, Double>(i,Math.cos(i)));
}

List<LineSeriesItem<Double, Double>> sinPoints = new
ArrayList<LineSeriesItem<Double, Double>>();
for (double i = 0; i < 2 * Math.PI; i+=0.4) {
sinPoints.add(new LineSeriesItem<Double, Double>(i,2 * Math.sin(i-.8)));
}

List<LineSeriesItem<Double, Double>> powPoints1 = new
ArrayList<LineSeriesItem<Double, Double>>();
for (double i = 0; i < 2 * Math.PI; i++) {
powPoints1.add(new LineSeriesItem<Double, Double>(i,2.5 + Math.pow(i / 4,
2)));
}

List<LineSeriesItem<Double, Double>> powPoints2 = new
ArrayList<LineSeriesItem<Double, Double>>();
for (double i = 0; i < 2 * Math.PI; i ++) {
powPoints2.add(new LineSeriesItem<Double, Double>(i,-2.5 - Math.pow(i /
4,
2)));
}

LineSeriesChart<Double,Double> lineChart = new
LineSeriesChart<Double,Double>("Line Style Options");
lineChart.addValue(cosPoints);
lineChart.addValue(sinPoints);
lineChart.addValue(powPoints1);
lineChart.addValue(powPoints2);
SeriesDefaults seriesDefaults = new SeriesDefaults();
seriesDefaults.rendererOptions(new RendererOptions().smooth(true));
lineChart.setSeriesDefaults(seriesDefaults);
lineChart.addSerie(new Serie().lineWidth(2).markerOptions(new
MarkerOptions().style("diamond")));
lineChart.addSerie(new Serie().showLine(false).markerOptions(new
MarkerOptions().size(7f).style("x")));
lineChart.addSerie(new Serie().markerOptions(new
MarkerOptions().style("circle")));
lineChart.addSerie(new Serie().lineWidth(5).markerOptions(new
MarkerOptions().style("filledSquare").size(10f)));

return lineChart;
}

On Tue, Mar 13, 2012 at 10:55 AM, Decebal Suiu <
[email protected]

wrote:

Exact.

I wrote some code but I cannot obtains a LineChart with two series. I
don't know the relations between serie and the values from that serie
(jqplot it's new for me).

Thanks,
Decebal

On Tue, Mar 13, 2012 at 3:47 PM, Inaiat Henrique
[email protected]
wrote:

Hello,

a example like this (Line Style Options)
http://www.jqplot.com/deploy/dist/examples/line-charts.html ?

Thanks.

On Tue, Mar 13, 2012 at 9:24 AM, Decebal Suiu <
[email protected]

wrote:

Hi

It's series supported for LineChart? Can you write a simple demo (a
new
method in JqPlotSample is enough)?

Thanks,
Decebal


Reply to this email directly or view it on GitHub:
#1


Reply to this email directly or view it on GitHub:

#1 (comment)


Reply to this email directly or view it on GitHub:

#1 (comment)


Reply to this email directly or view it on GitHub:

#1 (comment)


Reply to this email directly or view it on GitHub:
#1 (comment)

@decebals
Copy link
Author

It's ok now but I have some problems with LineSeriesChar.setFillZero()t:
java.lang.NullPointerException
at br.com.digilabs.jqplot.chart.AbstractChart.setFillZero(AbstractChart.java:395)

And another little observations:

  • implements toString(), hashCode() and equals() for LineSeriesItem
  • in my opinion it's better to put setColor on Serie rather
    setSeriesColor on Chart

I'm curios to see if the animation option pulled by balamaci it's functional.

Best regards,
Decebal

On Tue, Mar 13, 2012 at 11:51 PM, Inaiat Henrique
[email protected]
wrote:

Hello,

I developed LineSeriesChart. Checkout latest version. See example:

private LineSeriesChart<Double,Double> lineSeries() {
List<LineSeriesItem<Double, Double>> cosPoints = new
ArrayList<LineSeriesItem<Double, Double>>();
for (double i = 0; i < 2 * Math.PI; i++) {
cosPoints.add(new LineSeriesItem<Double, Double>(i,Math.cos(i)));
}

List<LineSeriesItem<Double, Double>> sinPoints = new
ArrayList<LineSeriesItem<Double, Double>>();
for (double i = 0; i < 2 * Math.PI; i+=0.4) {
sinPoints.add(new LineSeriesItem<Double, Double>(i,2 * Math.sin(i-.8)));
}

List<LineSeriesItem<Double, Double>> powPoints1 = new
ArrayList<LineSeriesItem<Double, Double>>();
for (double i = 0; i < 2 * Math.PI; i++) {
powPoints1.add(new LineSeriesItem<Double, Double>(i,2.5 + Math.pow(i / 4,
2)));
}

List<LineSeriesItem<Double, Double>> powPoints2 = new
ArrayList<LineSeriesItem<Double, Double>>();
for (double i = 0; i < 2 * Math.PI; i ++) {
powPoints2.add(new LineSeriesItem<Double, Double>(i,-2.5 - Math.pow(i / 4,
2)));
}

LineSeriesChart<Double,Double> lineChart = new
LineSeriesChart<Double,Double>("Line Style Options");
lineChart.addValue(cosPoints);
lineChart.addValue(sinPoints);
lineChart.addValue(powPoints1);
lineChart.addValue(powPoints2);
 SeriesDefaults seriesDefaults = new SeriesDefaults();
seriesDefaults.rendererOptions(new RendererOptions().smooth(true));
lineChart.setSeriesDefaults(seriesDefaults);
 lineChart.addSerie(new Serie().lineWidth(2).markerOptions(new
MarkerOptions().style("diamond")));
lineChart.addSerie(new Serie().showLine(false).markerOptions(new
MarkerOptions().size(7f).style("x")));
lineChart.addSerie(new Serie().markerOptions(new
MarkerOptions().style("circle")));
lineChart.addSerie(new Serie().lineWidth(5).markerOptions(new
MarkerOptions().style("filledSquare").size(10f)));

return lineChart;
}

On Tue, Mar 13, 2012 at 10:55 AM, Decebal Suiu <
[email protected]

wrote:

Exact.

I wrote some code but I cannot obtains a LineChart with two series. I
don't know the relations between serie and the values from that serie
(jqplot it's new for me).

Thanks,
Decebal

On Tue, Mar 13, 2012 at 3:47 PM, Inaiat Henrique
[email protected]
wrote:

Hello,

a example like this (Line Style Options)
http://www.jqplot.com/deploy/dist/examples/line-charts.html ?

Thanks.

On Tue, Mar 13, 2012 at 9:24 AM, Decebal Suiu <
[email protected]

wrote:

Hi

It's series supported for LineChart? Can you write a simple demo (a new
method in JqPlotSample is enough)?

Thanks,
Decebal


Reply to this email directly or view it on GitHub:
#1


Reply to this email directly or view it on GitHub:

#1 (comment)


Reply to this email directly or view it on GitHub:
#1 (comment)


Reply to this email directly or view it on GitHub:
#1 (comment)

@balamaci
Copy link

Hi,
I think LineSeriesItem should not necessarily extend Number with the generics(don't know if only the first value or both can be not a number, see http://www.jqplot.com/tests/date-axes.php).

@decebals
Copy link
Author

The NPE from LineSeriesChart.setTicks() appears because in getChartConfiguration().getAxes() returns null.
With these lines in constructor I resolved the problem:
getChartConfiguration().createAxesDefaults().setLabelRenderer(JqPlotResources.CanvasAxisLabelRenderer);
getChartConfiguration().createXAxis().setPad(0F);
(it's a copy/paste from constructor of LineChart)

The main problem is that setTicks() doesn't work in LineChart and any variations of this (LabeledLineChart and LineSeriesChart). I try to create a line chart (with series) that contains date on X axis and Number on Y Axes.

@inaiat
Copy link
Owner

inaiat commented Mar 16, 2012

Ok. I will change to Serializable.

Thanks.
Em 16/03/2012 04:30, "Serban Balamaci" <
[email protected]>
escreveu:

Hi,
I think LineSeriesItem should not necessarily extend Number with the
generics(don't know if only the first value or both can be not a number,
see http://www.jqplot.com/tests/date-axes.php).


Reply to this email directly or view it on GitHub:
#1 (comment)

@inaiat
Copy link
Owner

inaiat commented Mar 16, 2012

Hi,

Can you send me a example?

Thanks in advanced.
Em 16/03/2012 06:37, "Decebal Suiu" <
[email protected]>
escreveu:

The NPE from LineSeriesChart.setTicks() appears because in
getChartConfiguration().getAxes() returns null.
With these lines in constructor I resolved the problem:

getChartConfiguration().createAxesDefaults().setLabelRenderer(JqPlotResources.CanvasAxisLabelRenderer);
getChartConfiguration().createXAxis().setPad(0F);
(it's a copy/paste from constructor of LineChart)

The main problem is that setTicks() doesn't work in LineChart and any
variations of this (LabeledLineChart and LineSeriesChart). I try to create
a line chart (with series) that contains date on X axis and Number on Y
Axes.


Reply to this email directly or view it on GitHub:
#1 (comment)

@decebals
Copy link
Author

I created an issue on jgplot4java and added test code.

On Fri, Mar 16, 2012 at 12:44 PM, Inaiat Henrique
[email protected]
wrote:

Hi,

Can you send me a example?

Thanks in advanced.
Em 16/03/2012 06:37, "Decebal Suiu" <
[email protected]>
escreveu:

The NPE from LineSeriesChart.setTicks() appears because in
getChartConfiguration().getAxes() returns null.
With these lines in constructor I resolved the problem:

 getChartConfiguration().createAxesDefaults().setLabelRenderer(JqPlotResources.CanvasAxisLabelRenderer);
       getChartConfiguration().createXAxis().setPad(0F);
(it's a copy/paste from constructor of LineChart)

The main problem is that setTicks() doesn't work in LineChart and any
variations of this (LabeledLineChart and LineSeriesChart). I try to create
a line chart (with series) that contains date on X axis and Number on Y
Axes.


Reply to this email directly or view it on GitHub:
#1 (comment)


Reply to this email directly or view it on GitHub:
#1 (comment)

@balamaci
Copy link

I've tried to use LineSeriesChart with DateAxisRenderer. The LineSeriesChart does not have @JqPlotPluginJqPlotResources.DateAxisRenderer and so it does not contribute the necessary js resource. After I changed it, it worked. Any reason why LineSeriesChart should have the same @JqPlotPluginJqPlotResources as LabeledLineChart
I've seen it exists also LabeledLineChart. It's not real clear to me right now why and when I should use LabeledLineChart instead of LineSeriesChart(and why not just have only one type).

@inaiat
Copy link
Owner

inaiat commented Mar 16, 2012

Hi,

I change LineSeriesItem to extend Serializable.

Thanks.

On Fri, Mar 16, 2012 at 4:30 AM, Serban Balamaci <
[email protected]

wrote:

Hi,
I think LineSeriesItem should not necessarily extend Number with the
generics(don't know if only the first value or both can be not a number,
see http://www.jqplot.com/tests/date-axes.php).


Reply to this email directly or view it on GitHub:
#1 (comment)

@inaiat
Copy link
Owner

inaiat commented Mar 16, 2012

Hi,

the final json result is different. When I started the project I thought
the best model was abstract all objects, like some parts of java Swing, but
is harder to build a simple LineChart. So, I thought write some classes to
help development like BubbleCharts and BarChart that encapsulates
complexity. I don't know thats is right way. What do you think?

Best Regards.

On Fri, Mar 16, 2012 at 5:24 PM, Serban Balamaci <
[email protected]

wrote:

I've tried to use LineSeriesChart with DateAxisRenderer. The
LineSeriesChart does not have @JqPlotPluginJqPlotResources.DateAxisRenderer
and so it does not contribute the necessary js resource. After I changed
it, it worked. Any reason why LineSeriesChart should have the same
@JqPlotPluginJqPlotResources as LabeledLineChart
I've seen it exists also LabeledLineChart. It's not real clear to me right
now why and when I should use LabeledLineChart instead of
LineSeriesChart(and why not just have only one type).


Reply to this email directly or view it on GitHub:
#1 (comment)

@GaryChu2186
Copy link

Hello,

I try to create a line series chart that have date on X axis, but it looks like i can't do that because it only take numbers, I am new to this library so maybe I am missing a few things?

any help will be appreciated

Thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants