This is a migrated thread and some comments may be shown as answers.

Problem in Line chart to give different palatte for lines

1 Answer 50 Views
Chart
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Jake
Top achievements
Rank 1
Jake asked on 15 Sep 2014, 12:35 PM
Hi Team,

i m working on line chart series and i gave custom palette for line but its not applying , can some body help for it !
please . here what i m trying from your example only


public RadCartesianChartView lineChartView() {

        try {

            initData();

            linechartView = new RadCartesianChartView(this);
            LineSeries lineSeries = new LineSeries(this);

            lineSeries.setCategoryBinding(new DataPointBinding() {
                @Override
                public Object getValue(Object o) {
                    return ((MonthResults) o).getMonth();
                }
            });
            lineSeries.setValueBinding(new DataPointBinding() {
                @Override
                public Object getValue(Object o) {
                    return ((MonthResults) o).getResult();
                }
            });
            lineSeries.setData(this.monthResults);

            // lineSeries.setStrokeColor(Color.RED);

            ChartPalette customPalette = new ChartPalette();
            PaletteEntryCollection collection = new PaletteEntryCollection();

            collection.setFamily(lineSeries.paletteFamily());
            PaletteEntry entry = new PaletteEntry(Color.RED);
            collection.add(entry);
            customPalette.seriesEntries().add(collection);
            linechartView.setPalette(customPalette);
            linechartView.setSelectionPalette(customPalette);
            linechartView.getSeries().add(lineSeries);

            CategoricalAxis horizontalAxis = new CategoricalAxis(this);
            linechartView.setHorizontalAxis(horizontalAxis);

            LinearAxis verticalAxis = new LinearAxis(this);
            linechartView.setVerticalAxis(verticalAxis);

            ChartPanAndZoomBehavior behavior = new ChartPanAndZoomBehavior();

            behavior.setZoomMode(ChartPanZoomMode.VERTICAL);
            behavior.setPanMode(ChartPanZoomMode.BOTH);
            linechartView.getBehaviors().add(behavior);
            linechartView.getBehaviors().add(new ChartSelectionBehavior());

        } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        return linechartView;

    }



initdata Function

private void initData() {

        monthResults = new ArrayList<MonthResults>();
        monthResults.add(new MonthResults("Jan", 25, 10));
        monthResults.add(new MonthResults("Feb", 30, 10));
        monthResults.add(new MonthResults("Mar", 40, 20));

        // monthResults.add(new MonthResults("Mar", 15));
        // monthResults.add(new MonthResults("Apr", 17));
        // monthResults.add(new MonthResults("May", 21));
        // monthResults.add(new MonthResults("Jun", 28));
        // monthResults.add(new MonthResults("Jul", 32));
        // monthResults.add(new MonthResults("Aug", 48));
        // monthResults.add(new MonthResults("Sep", 51));
        // monthResults.add(new MonthResults("Oct", 42));
        // monthResults.add(new MonthResults("Nov", 57));
        // monthResults.add(new MonthResults("Dec", 60));

    }

1 Answer, 1 is accepted

Sort by
0
Victor
Telerik team
answered on 18 Sep 2014, 02:06 PM
Hi Jake,

Thanks for the question.
Why don't you simply clone the existing palette and tweak it? It's easier. Take a look at the example below:
RadCartesianChartView chartView = new RadCartesianChartView(this);
ChartPalette customPalette = chartView.getPalette().clone();
PaletteEntry entry = customPalette.getEntry(ChartPalette.LINE_FAMILY, 0);
entry.setStroke(Color.RED);
entry.setStrokeWidth(10);
chartView.setPalette(customPalette);


Regards,
Victor
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
Chart
Asked by
Jake
Top achievements
Rank 1
Answers by
Victor
Telerik team
Share this question
or