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