@@ -180,9 +180,14 QChart* ThemeWidget::createAreaChart() const | |||||
180 | QChart *chart = new QChart(); |
|
180 | QChart *chart = new QChart(); | |
181 | chart->setTitle("Area chart"); |
|
181 | chart->setTitle("Area chart"); | |
182 | { |
|
182 | { | |
|
183 | QString name("Series "); | |||
|
184 | int nameIndex = 0; | |||
183 | for (int i(0); i < m_dataTable.count(); i++) { |
|
185 | for (int i(0); i < m_dataTable.count(); i++) { | |
184 | QLineSeries *series1 = new QLineSeries(chart); |
|
186 | QLineSeries *series1 = new QLineSeries(chart); | |
185 | QLineSeries *series2 = new QLineSeries(chart); |
|
187 | QLineSeries *series2 = new QLineSeries(chart); | |
|
188 | series1->setName(name + QString::number(nameIndex) + QString(" lo")); | |||
|
189 | series2->setName(name + QString::number(nameIndex) + QString(" hi")); | |||
|
190 | nameIndex++; | |||
186 | foreach (Data data, m_dataTable[i]) { |
|
191 | foreach (Data data, m_dataTable[i]) { | |
187 | series1->add(data.first); |
|
192 | series1->add(data.first); | |
188 | series2->add(QPointF(data.first.x(), 0.0)); |
|
193 | series2->add(QPointF(data.first.x(), 0.0)); | |
@@ -223,10 +228,14 QChart* ThemeWidget::createLineChart() const | |||||
223 | // line chart |
|
228 | // line chart | |
224 | QChart* chart = new QChart(); |
|
229 | QChart* chart = new QChart(); | |
225 | chart->setTitle("Line chart"); |
|
230 | chart->setTitle("Line chart"); | |
|
231 | QString name("Series "); | |||
|
232 | int nameIndex = 0; | |||
226 | foreach (DataList list, m_dataTable) { |
|
233 | foreach (DataList list, m_dataTable) { | |
227 | QLineSeries *series = new QLineSeries(chart); |
|
234 | QLineSeries *series = new QLineSeries(chart); | |
228 | foreach (Data data, list) |
|
235 | foreach (Data data, list) | |
229 | series->add(data.first); |
|
236 | series->add(data.first); | |
|
237 | series->setName(name + QString::number(nameIndex)); | |||
|
238 | nameIndex++; | |||
230 | chart->addSeries(series); |
|
239 | chart->addSeries(series); | |
231 | } |
|
240 | } | |
232 | return chart; |
|
241 | return chart; | |
@@ -260,10 +269,14 QChart* ThemeWidget::createSplineChart() const | |||||
260 | { // spine chart |
|
269 | { // spine chart | |
261 | QChart* chart = new QChart(); |
|
270 | QChart* chart = new QChart(); | |
262 | chart->setTitle("Spline chart"); |
|
271 | chart->setTitle("Spline chart"); | |
|
272 | QString name("Series "); | |||
|
273 | int nameIndex = 0; | |||
263 | foreach (DataList list, m_dataTable) { |
|
274 | foreach (DataList list, m_dataTable) { | |
264 | QSplineSeries *series = new QSplineSeries(chart); |
|
275 | QSplineSeries *series = new QSplineSeries(chart); | |
265 | foreach (Data data, list) |
|
276 | foreach (Data data, list) | |
266 | series->add(data.first); |
|
277 | series->add(data.first); | |
|
278 | series->setName(name + QString::number(nameIndex)); | |||
|
279 | nameIndex++; | |||
267 | chart->addSeries(series); |
|
280 | chart->addSeries(series); | |
268 | } |
|
281 | } | |
269 | return chart; |
|
282 | return chart; | |
@@ -273,10 +286,14 QChart* ThemeWidget::createScatterChart() const | |||||
273 | { // scatter chart |
|
286 | { // scatter chart | |
274 | QChart* chart = new QChart(); |
|
287 | QChart* chart = new QChart(); | |
275 | chart->setTitle("Scatter chart"); |
|
288 | chart->setTitle("Scatter chart"); | |
|
289 | QString name("Series "); | |||
|
290 | int nameIndex = 0; | |||
276 | foreach (DataList list, m_dataTable) { |
|
291 | foreach (DataList list, m_dataTable) { | |
277 | QScatterSeries *series = new QScatterSeries(chart); |
|
292 | QScatterSeries *series = new QScatterSeries(chart); | |
278 | foreach (Data data, list) |
|
293 | foreach (Data data, list) | |
279 | series->add(data.first); |
|
294 | series->add(data.first); | |
|
295 | series->setName(name + QString::number(nameIndex)); | |||
|
296 | nameIndex++; | |||
280 | chart->addSeries(series); |
|
297 | chart->addSeries(series); | |
281 | } |
|
298 | } | |
282 | return chart; |
|
299 | return chart; |
@@ -151,11 +151,13 void LegendMarker::changed() | |||||
151 | { |
|
151 | { | |
152 | case LegendMarkerTypeSeries: { |
|
152 | case LegendMarkerTypeSeries: { | |
153 | QXYSeries* s = static_cast<QXYSeries*> (m_series); |
|
153 | QXYSeries* s = static_cast<QXYSeries*> (m_series); | |
|
154 | setPen(s->pen()); | |||
154 | setBrush(s->brush()); |
|
155 | setBrush(s->brush()); | |
155 | setName(s->name()); |
|
156 | setName(s->name()); | |
156 | break; |
|
157 | break; | |
157 | } |
|
158 | } | |
158 | case LegendMarkerTypeBarset: { |
|
159 | case LegendMarkerTypeBarset: { | |
|
160 | setPen(m_barset->pen()); | |||
159 | setBrush(m_barset->brush()); |
|
161 | setBrush(m_barset->brush()); | |
160 | setName(m_barset->name()); |
|
162 | setName(m_barset->name()); | |
161 | break; |
|
163 | break; |
@@ -428,14 +428,14 void QLegend::appendMarkers(QXYSeries* series) | |||||
428 | */ |
|
428 | */ | |
429 | void QLegend::appendMarkers(QBarSeries *series) |
|
429 | void QLegend::appendMarkers(QBarSeries *series) | |
430 | { |
|
430 | { | |
431 | foreach(QBarSet* s, series->barSets()) { |
|
431 | foreach(QBarSet* set, series->barSets()) { | |
432 | LegendMarker* marker = new LegendMarker(series, s, this); |
|
432 | LegendMarker* marker = new LegendMarker(series, set, this); | |
433 | marker->setName(s->name()); |
|
433 | marker->setName(set->name()); | |
434 | marker->setPen(s->pen()); |
|
434 | marker->setPen(set->pen()); | |
435 | marker->setBrush(s->brush()); |
|
435 | marker->setBrush(set->brush()); | |
436 | connect(marker, SIGNAL(clicked(QBarSet *, Qt::MouseButton)), |
|
436 | connect(marker, SIGNAL(clicked(QBarSet *, Qt::MouseButton)), | |
437 | this, SIGNAL(clicked(QBarSet *, Qt::MouseButton))); |
|
437 | this, SIGNAL(clicked(QBarSet *, Qt::MouseButton))); | |
438 | connect(s, SIGNAL(valueChanged()), marker, SLOT(changed())); |
|
438 | connect(set, SIGNAL(valueChanged()), marker, SLOT(changed())); | |
439 | connect(marker, SIGNAL(destroyed()), this, SLOT(handleMarkerDestroyed())); |
|
439 | connect(marker, SIGNAL(destroyed()), this, SLOT(handleMarkerDestroyed())); | |
440 | m_markers.append(marker); |
|
440 | m_markers.append(marker); | |
441 | childItems().append(marker); |
|
441 | childItems().append(marker); | |
@@ -447,15 +447,15 void QLegend::appendMarkers(QBarSeries *series) | |||||
447 | */ |
|
447 | */ | |
448 | void QLegend::appendMarkers(QPieSeries *series) |
|
448 | void QLegend::appendMarkers(QPieSeries *series) | |
449 | { |
|
449 | { | |
450 | foreach(QPieSlice* s, series->slices()) { |
|
450 | foreach(QPieSlice* slice, series->slices()) { | |
451 | LegendMarker* marker = new LegendMarker(series, s, this); |
|
451 | LegendMarker* marker = new LegendMarker(series, slice, this); | |
452 | marker->setName(s->label()); |
|
452 | marker->setName(slice->label()); | |
453 | marker->setPen(s->pen()); |
|
453 | marker->setPen(slice->pen()); | |
454 | marker->setBrush(s->brush()); |
|
454 | marker->setBrush(slice->brush()); | |
455 | connect(marker, SIGNAL(clicked(QPieSlice *, Qt::MouseButton)), |
|
455 | connect(marker, SIGNAL(clicked(QPieSlice *, Qt::MouseButton)), | |
456 | this, SIGNAL(clicked(QPieSlice *, Qt::MouseButton))); |
|
456 | this, SIGNAL(clicked(QPieSlice *, Qt::MouseButton))); | |
457 | connect(s, SIGNAL(changed()), marker, SLOT(changed())); |
|
457 | connect(slice, SIGNAL(changed()), marker, SLOT(changed())); | |
458 | connect(s, SIGNAL(destroyed()), marker, SLOT(deleteLater())); |
|
458 | connect(slice, SIGNAL(destroyed()), marker, SLOT(deleteLater())); | |
459 | connect(marker, SIGNAL(destroyed()), this, SLOT(handleMarkerDestroyed())); |
|
459 | connect(marker, SIGNAL(destroyed()), this, SLOT(handleMarkerDestroyed())); | |
460 | m_markers.append(marker); |
|
460 | m_markers.append(marker); | |
461 | childItems().append(marker); |
|
461 | childItems().append(marker); |
General Comments 0
You need to be logged in to leave comments.
Login now